JsonStringToMap

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 string

Examples

JsonStringToMap('{"userID": 1, "userName": {"lastName": "Doe", "firstName" : "John"} }') returns a map with two key-value pairs:

  • userID: 1 
  • userName: {"lastName":"Doe","firstName":"John"}
To extract the lastName, apply the function twice:

JsonStringToMap(JsonStringToMap('{"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.

Return value datatype

String

Impact of null value

If input is null, returns null.


Feedback and Knowledge Base