Problem displaying Json in variables - Forum

Forum Navigation
You need to log in to create posts and topics.

Problem displaying Json in variables

LoadJSON "https://jsonplaceholder.typicode.com/todos/4" [myVar]

I use this tool to show a "id" in a variable  --->   [myvar('id')]
My variable is in the text
But the error shows!
What is the problem ?

 

 

 

Hi @yasin,

you wrote the variable wrong.

Is [myVar] and not [myvar]

First you used [myVar] for the json and then you used [myvar ('id')]  to access to the 'id' field.

Use [myVar ('id')]

luishp and javadrajabihakami have reacted to this post.
luishpjavadrajabihakami

@yasin also note that LoadJSON takes time to load the data and it will not be inmediately available. That's the reason I added LoadAsyncJSON later, it will call a subroutine as soon as the data has been loaded.

Regards.

YASIN has reacted to this post.
YASIN
Quote from roccocogliano on August 21, 2021, 6:41 pm

Hi @yasin,

you wrote the variable wrong.

Is [myVar] and not [myvar]

 

I know this has nothing to do with my problem :)

Quote from roccocogliano on August 21, 2021, 6:46 pm

First you used [myVar] for the json and then you used [myvar ('id')]  to access to the 'id' field.

Use [myVar ('id')]

Test the attachment to better understand the content

Uploaded files:
  • You need to login to have access to uploads.

You're right @yasin, it doesn't work. We must first assign [myVar ('id)] to another variable and then use that.
eg. setVar [id] [myVar ('id')] and then use [id].

I corrected your example, try it. It works with correction

@luishp is this functioning normal?

Uploaded files:
  • You need to login to have access to uploads.

@luishp @yasin

maybe it depends on loadJSON being synchronous.

You should try the asynchronous function loadAsyncJSON

@roccocogliano @yasin you can't show a complex variable directly on screen.
What Rocco have done is the correct path to solve the problem. You can also use a filter as described here:

https://webhelp.visualneo.com/VariableArrays.html
https://webhelp.visualneo.com/VariableFilters.html

Best regards.

roccocogliano has reacted to this post.
roccocogliano