Convesion of a JSON return type via a scripting transform

Hi all,

I'm attempting to convert a JSON return type from a named query that is considered an 'object type' when the values are inserted into the properties tab to an 'array type'. So for example lets say I have a list of 50 entries that look like this:

[{"String1": 10, "String2": 20},{"String1": 10, "String2": 20},{"String1": 10, "String2": 20}....{"String1": 10, "String2": 20}]

How would I go about changing this previous example to something more like this:

[[0: 10, 1: 20],[0: 10, 1: 20],[0: 10, 1: 20]....[0: 10, 1: 20]]

Also note the return type is considered an 'array.array' type in the python transform.

How would I go about editing this?

Thank you,

Cam

###############################################
Edit:

What I'm attempting to do so you have a full scope of my problem is this: I want to take geographical data that I've collected and stored in a database and query this data so that it can be used by the mapping component in perspective to plot out the users route that they have taken over X time.

The problem I'm having and why I'm approaching it this way is this: I cannot make a static webdev file as I want to plotting to be dynamic so that the user can see their route as they as moving around and the best way it seems to me to do this is the querie the database and bind that result to the coordinates section under the geoJSON section of the mapping component.

The reason I need it in the format I do is because for Ignition to accept the result it needs to be in the form of array of arrays because if its an array of objects the map component gets an error overlay

What have you tried so far?

You may find the enumerate builtin and the dict class' values() method useful.

Sounds like dataset row/column subscripting. Just use dataset return type for the named query, and jsonify it in a transform. Going from dataset to json is "lossy", so should only be done at the point where Perspective needs it.

You might find this helpful:

My first attempt was to convert the JSON return type to a string an then correct the formatting with regex and after I was halfway done I realized I couldn't convert it back to any acceptable Ignition datatype that would have worked and then stopped that attempt.

My second attempt was similar to using what you suggested. This morning I attempted to do it again to see if I had just overlooked something but I cannot seem to make it work with this way either because for Ignition to accept it, it needs to be "[[..],[..],[..]]" not "[{..},{..},{..}]" in terms of bracketing and I cant seem to find a way to change that.

Your code was helpful to an extent but it takes me to the same spot I was before if I just use the JSON return type from the named querie. I'll update my post to be a little more specific about what I'm attempting to do @PGriffith @pturmel