Class Common
Common utility methods for the GenAI SDK to work with JSON.
public static class Common
- Inheritance
-
Common
- Inherited Members
Methods
GetValueByPath(JsonNode, string[])
Gets the value of an object by a path.
Common.GetValueByPath(containerJsonNode, new string[]{"secondMember", "childMember"})
public static JsonNode? GetValueByPath(JsonNode obj, string[] keys)
Parameters
Returns
MoveValueByPath(JsonNode, IDictionary<string, string>)
Moves values from source paths to destination paths.
Example: MoveValueByPath( {'requests': [{'content': v1}, {'content': v2}]}, {'requests[].*': 'requests[].request.*'} ) -> {'requests': [{'request': {'content': v1}}, {'request': {'content': v2}}]}
public static void MoveValueByPath(JsonNode data, IDictionary<string, string> paths)
Parameters
dataJsonNodepathsIDictionary<string, string>
SetValueByPath(JsonObject, string[], object)
Sets the value of an object by a path.
Common.SetValueByPath(containerJsonObject, new string[]{"secondMember", "childMember"}, 42);
public static void SetValueByPath(JsonObject jsonObject, string[] path, object value)
Parameters
jsonObjectJsonObjectpathstring[]valueobject