[ardoJSON] JSON without attribute's names?

[ardoJSON] JSON without attribute's names?

Forge Component
Published on 30 Aug by Ricardo Silva
20 votes
Published on 30 Aug by Ricardo Silva
I tried to consume an weird JSON from an external service ( http://www.westclicks.com/webservices/?f=json&c=fr )
I coulnd't do it with ardoJSON. Is there an easy way to do this? =)


I don't see anything weird in that JSON.

Have you tried having it go through REST WebServices to generate the required structures, or better yet, to use the OutSystems Platform's builtin REST capabilities?
I call this JSON weird because instead of being on the format "propertyname" : "value" , it is given as "value" : "related value".

Yes, I tried to use the Platform's builtin REST capabilities. 

Giving you a small example, the builtin REST capabilities generate from the output below a structure with the attributes AI, AS, AL, where I would like it to be read to a structure with only 2 attributes (Code and Name) instead of N attributes.




Ok, if the structure is fully dynamic with different attributes, neither the current implementation of ardoJSON or the Platform's REST capabilities will be of much use, as they're based on structures with fixed attributes.

This kind of use of a JSON as a dictionary is indeed weird and not the norm.

Is this the only instance where you have this kind of requirements? Or do you have other webservices with this kind of features?

It should be rather easy to extend ardoJSON to introspect the JSON to allow you to list properties and values.

Do you know in advance what you're looking for? For example, do you know, without looking at the JSON, that you'll have a key for AI on this JSON ? If so, you can probably use JSONSelect for your use-case. 
I'm considering adding this functionality to ardoJSON. Wait for more news tomorrow :)
Version 1.8 of ardoJSON adds an action to allow you to dynamically process JSON objects.

This should fit your requirements. Please let me know if you find any issue.
Thank you very much Ricardo! It's awesome :)))
Hi Ricardo,

In this new version its possible to use atribute Label instead atribute Name?
This is importante because I need to user translated values.

No, that information only exists in the OML. It doesn't persist to the generated code.

I can't access that information from an extension, I believe.
as of version 1.9 of ardoJSON there is now a new possibility to tackle these issues. Simply use JSON_Listify to convert your dictionary-like objects into lists of key/value pairs.

This, I hope, offers more pre-processing capabilities than the JSON_GetAttributes option.
Hi Ricardo,

in this latest version what should be the structure of the path we need to pass on the JSON_listify function?

That would be the path to the element you want to listify.

For example, in the following JSON if you want to listify the something attribute, you use "something" as the path parameter. If you want to listify the root, you use an empty string, if you want to listify the bananas object, you use "something.bananas".

 something : {
   "bananas": {
     "banana1": 10,
     "banana2": 2
   "apples": {
Hi again Ricardo,

thanks for your help.

Now i'm having an error that says "empty record... does not compute".

I'm using the function "listify" on the file that it's attached, then I use the function "JSON2recordlist" that receive the output of the function"listify" an occurs the error listed above.

What i'm doing wrong?

Thanks in advance.
Can you give a sample espace with what you're doing ?
Hi Ricardo,

here it is.


Hi Ricardo,

do you have any idea why this is happening? I'm litle bit stuck with this error. 
Do you have any idea how can I work around this?

I have not yet had time to look closely into this.

I'll reply when I do :)
Thanks ;)
Hello Gonçalo,

I've taken a look at your module and it seems nothing is wrong with the lsoa.crimes part.

The error is coming from the lsoa.geometry.coordinates as you only define one list for it and it is actually a list of lists of lists.

I recommend that you use RESTWebServices or the consume REST functionality of the OutSystems Platform to generate the structured for this part (should work).

Best regards,
Ricardo Silva
Hi Ricardo,

thanks for your help.
Your tip was precious! The error was in fact on that part of the JSON. With RESTWebservices I realized what structure I needed for that (not common) part of the JSON.