Unable decode JSON

Hello, i vould like decocde this json text to send into two gobal variable
fist is date1 with "value" from "custom_fields_list" where "id=24683" and the second is date2 with "value" from "custom_fields_list" where "id=24684"

{
"id": "654",
"title": "Titre",
"reference": "My Ref",
"description": "",
"serial_number": "508277",
"id_customer_supplier": "271850",
"custom_fields_list": [
{
"id": "24683",
"title": "Date1",
"value": "2023-02-01",
"value_text": "01/02/2023"
}
{
"id": "24684",
"title": "Date2",
"value": "2023-02-01",
"value_text": "01/02/2023"
}

],

}

Thank for your help

do these edits

and copy and paste the wholes json string into the site below so you can see the structure

1 Like

ok but my problem is how can i get value from date1 and value from date2 ?

Try to use

list by walking path [make a list, custom_fields_list, Walk at all level, value_text]

This will return all the dates as a list

ok, i've made those 2 blocs

but now how can i send to lblAchat value where id=24683 and in lblInstall value where id = 24684

Both will return same list of values . If you have only two values then (so) use select list item list block , use index 1 for first lable and use 2 for second list

Else just use one common procedure

Sory but i don't undestand

Will you store too many values in future in the dictionary? Or only these two values

I only need those two value
i can use ID to make difference betwwen those 2 values.

Here is my take on this, using one of the new list blocks.

It might be tighter using the reduce block.


Capture
JSON_map_reduce.aia (3.6 KB)



Extra steps might be needed depending on your JSON source.

Here's another way todo this with the list reduce block:


Capture
JSON_map_reduce.aia (4.9 KB)

I assumed only one pair list would be returned, allowing the cumulative text JOIN to work.

1 Like

another way

Thank for your help but i always got error

my code is like that

error is "Bad agruments to Elements
The operationElements cannot accept the argument:, [""]

Export your .aia file and upload it here.
export_and_upload_aia

You load Elements from global customField, but where do you load global customField?

P.S. Elements will only accept a list, not a piece of text.
Look in the list blocks palette for the block that creates an empty list if you want an empty list.

I've made little modifcation because usualy JSON came from website

Mat5.aia (65.0 KB)



This will eliminate one source of that error message.

Check the rest of your global inits yourself.

It's work !!

thank for your help !!!

Not sure why everyone has made it so complicated ?

2 Likes

He doesn't want both these value in a label as a list

Instead as per id he want to print the value . So we have suggested the way