Description
Converts a string expression that contains a JSON object to a map (key:value pairs). From the map you can extract fields using the notation map#‘fieldname’.Syntax
JsonStringToMap(string_expression)
Arguments
string_expression - JSON stringExamples
JsonStringToMap('{"userID": 1, "userName": {"lastName": "Doe", "firstName" : "John"} }') returns a map with two key-value pairs:
- userID: 1
- userName:
{"lastName":"Doe","firstName":"John"}
{"userID": 1, "userName": {"lastName": "Doe", "firstName" : "John"} }’)#‘userName’)#‘lastName’ returns Doe
Notes
The function only converts the first level hierarchy to a map. To map lower hierarchies, either use JsonExtract or extract the nested object string using the map notation (field#'objectname') and apply the function JsonStringToMap to it as well. For more information, read How do I process JSON data.