Table of Contents

Class Common

Namespace
Google.GenAI
Assembly
Google.GenAI.dll

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

obj JsonNode
keys string[]

Returns

JsonNode

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

data JsonNode
paths IDictionary<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

jsonObject JsonObject
path string[]
value object