Hello @Kothai Ramanathan and thank you for your question. Please allow me to demonstrate how to convert and manipulate in an easier way than direct string parsing.
In this (attatched) pipeline, I start with an object parameter:
{"id":1,"complex":{"foo":"bar","val":true}}
I will show how to convert to string, and back, then extracting a property.
Suppose I need to store my object into a variable. What I do is use a string type variable and cast the object to string.
@string(pipeline().parameters.input)
Note that doing so adds in escape characters.
Next I will parse it back from string to object, and extract a property.
@json(variables('asString')).complex.foo
The json()
un-escapes and converts into an object. Then I can extract individual properties.
If I wanted to get the boolean property val
I can do that and store in a boolean type variable instead of string.
If I wanted to capture a complex sub-object rather than a single primitive property, I would need to convert back to string again.
@string( json(variables('asString')).complex )
In rare cases I have seen json stored as string inside another object. In such cases I have used multiple json()
calls to achieve my objectives.
Please let me know if this helps or if you have any questions.
Thank you
Martin