Skip to content

Commit 8399760

Browse files
committed
Better identification of nested objects
Signed-off-by: Daniel Widdis <[email protected]>
1 parent 3705ba5 commit 8399760

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

plugin/src/main/java/org/opensearch/ml/utils/MLNodeUtils.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,13 @@ public static String processRemoteInferenceInputDataSetParametersValue(String in
109109
if (value.isTextual()) {
110110
String textValue = value.asText();
111111
try {
112-
// Only try to parse as JSON if it looks like a JSON object or array
113-
if ((textValue.startsWith("{") && textValue.endsWith("}"))
114-
|| (textValue.startsWith("[") && textValue.endsWith("]"))) {
115-
// Try to parse the string as JSON
116-
JsonNode parsedValue = mapper.readTree(textValue);
117-
// If successful, replace the string with the parsed JSON
112+
// Try to parse the string as JSON
113+
JsonNode parsedValue = mapper.readTree(textValue);
114+
// Only replace if the parsed value is an object or array
115+
if (parsedValue.isObject() || parsedValue.isArray()) {
118116
parametersNode.set(key, parsedValue);
119117
} else {
118+
// Leave it as-is if the parsed value is a primitive
120119
parametersNode.set(key, value);
121120
}
122121
} catch (IOException e) {

0 commit comments

Comments
 (0)