How do I parse a JSON string into a dictionary when some of the values in the key-value pairs contain colon?

As a response from a GET request, I receive a JSON string as follows:


What blocks do I use to put these key-value pairs into a dictionary? The JsonTextDecodeWithDictionaries block is not able to convert the JSON string properly and gives an error saying that the key-value pairs are not well-formed. I'm assuming this is due to the presence of the colons in the timestamps.

I would be very grateful if someone here can help me with this. Really hope there's a solution to this!

As you rightly say, you have a JSON string. Drag out a web component, then use the JSONTextDecodeWithDictionaries block to convert to an object, then it will be a dictionary, then you can handle the key:pairs.

It parses okay for me.

Here's proof ...

and supporting draggable diagnostic routines

Thank you very much for your kind help! After tinkering around, I finally realised that the JSON string could not be parsed because there are square brackets around it i.e., what I received was actually


So all I needed to do was to remove the square brackets and the JsonTextDecodeWithDictionaries block was able to parse the JSON string properly. Thank you!

The Web JsonTextDecodeWithDictionaries block handled the [ ] correctly.
You could instead have selected item 1 of the resulting list, then applied dict lookup to item 1.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.