Is there a way to push an object at a dictionary ?

Hi.

I want to create a JSON from data that I extract from a variable copied from screen.

May someone guide me about how to push an object created in a loop to a list ?

Thanks
 

RSF

Well-known member
Have you tried MacroDroid's JSON Output action (in the Web Interactions action section)? If the object you've created is an array or dictionary, that might work; it converts the array or dictionary to a string containing JSON.
If that doesn't work, can you provide more information about what your object is and what it contains, and what you want in the "list" result?
 
Have you tried MacroDroid's JSON Output action (in the Web Interactions action section)? If the object you've created is an array or dictionary, that might work; it converts the array or dictionary to a string containing JSON.
If that doesn't work, can you provide more information about what your object is and what it contains, and what you want in the "list" result?
Hi.

I solved (by now) writing to a file. The result is an array of objects like this:

[{"nome" : "Maria Piedade Pires de Castro","inicio" : "29/03/2024 ","fim" : "31/03/2024","valor" : "900,00"},{"nome" : "Élita Pereira Carapina Palhares","inicio" : "08/03/2024 ","fim" : "10/03/2024","valor" : "660,00"},{"nome" : "Glaucilene Gomes Fernandes","inicio" : "15/03/2024 ","fim" : "17/03/2024","valor" : "660,00"},{"nome" : "Elisabeth Quesada Aragão","inicio" : "30/04/2024 ","fim" : "09/05/2024","valor" : "0,00"},{"nome" : "Elisabeth Quesada Aragão","inicio" : "20/04/2024 ","fim" : "30/04/2024","valor" : "0,00"},{"nome" : "Elisabeth Quesada Aragão","inicio" : "11/04/2024 ","fim" : "20/04/2024","valor" : "0,00"}]

Now I will try to send this to an endpoint (private API).

I will try this with JSON output. I wasn't able to use this feature during array creation but writing to a file worked like array PUSH.

Thanks for the suggestion.
 

RSF

Well-known member
One way to add to the end of an array ... similar to PUSH (to end), is to define the array key as the size of the array, e.g.
1711296049551.png

Just keep using [{size=array_name}] for the (manual) index option...

Then the JSON Output action will output those array entries, in order, into a string surrounded by {}
 
One way to add to the end of an array ... similar to PUSH (to end), is to define the array key as the size of the array, e.g.
View attachment 9078

Just keep using [{size=array_name}] for the (manual) index option...

Then the JSON Output action will output those array entries, in order, into a string surrounded by {}
Good idea. I will use this method on another situation.
 
Top