Skip to main content
January 20, 2025
Question

Remove Square brackets [] from a string of output from a!tojson

  • January 20, 2025
  • 9 replies
  • 0 views

I was sending a data in json format like { a!tojson("fruit": "apple") } but the output i was getting { "fruit": ["apple"] }but i need without square brackets . Could anyone please help me on this and thanks for advance

9 replies

nilanshum856600
January 20, 2025

To extract this value from JSON, first you need to parse the JSON using a!fromJson() to convert it into a dictionary. After that you can access the specific key to retrieve the value.

January 20, 2025

i need it inside the a!tojson function

nilanshum856600
January 20, 2025

I didn't get your point. From what I understood, you had a JSON input and you wanted to extract a value from it. Then why would you use a!toJson() ?

stefanhelzle0001
January 20, 2025

You could also use the extract() function.

extract("[""12hg""]", "[""", """]")

annap0005
January 20, 2025

Try this

a!localVariables( local!text: "[""12hg""]", stripwith( local!text,"["" ""]") )