How to use filename.json query results


Walter Hiller

Hello David,
I want to use a filename.json as a kind of INI file, means I want to set certain default variabels out of the database. Now my questions are:

1.
If I set a query, how can I get the unique result of this query into a local variabel. I.e I want to set a new var with the single [Record.Name] I get out of my query? With Setvar "[NewVar]" "[Record.Name]" "String" I get an error ... undefined

2.
My database.json has the fields Name and Value. After a query with only 1 result/record I want to use the following Syntax:
Setvar "[[Record.Name]]" "[Record.Value]" "String" - possible or a similar solution?

3.
Do you think abaout a RANDOM control/function ?

Thanks in advance
Walter


decsoft

Hello Walter,


Hello David,

I want to use a filename.json as a kind of INI file, means I want to set certain default variabels out of the database. Now my questions are:

1.
If I set a query, how can I get the unique result of this query into a local variabel. I.e I want to set a new var with the single [Record.Name] I get out of my query? With Setvar "[NewVar]" "[Record.Name]" "String" I get an error ... undefined

This is an interesting question. Currently the only way to parse a JSON file is to use the Report control, which in fact do more because visualice the JSON data in an HTML table. However, currently is not possible to parse a JSON string and retrieve it using App Builder available actions.

Definetively I need to think on this because it's very interesting. Of course if you use pure Javascript (with the StartJS and EndJS actions) probably you can do it, but my intention is to made it easy by using some kind of App Builder action or actions. Currently we can get the content of a file using "SimpleGet" action or the HttpClient control, but these are not thinked specifically for JSON files.

Currently I am a little sick, Walter, but I promise you I take a look at this question asa quickly as possible.

2.
My database.json has the fields Name and Value. After a query with only 1 result/record I want to use the following Syntax:
Setvar "[[Record.Name]]" "[Record.Value]" "String" - possible or a similar solution?

Anidated variables is something not available and probably it's not a thing which we can implement more or less easily, to be honest. However, we have actions like "Loop" or "While" and with the help of these actions and other possible actions to deal with JSON of course we must access individual JSON fields or iterate over records. Not currently, but probably in a near App Builder release.

3.
Do you think abaout a RANDOM control/function ?

Do you refer to a Random action which provide us a random number? Yes; of course some random related actions can be useful and probably you can count with something like that in a near release of the program. If I am wrong and you refer to other thing, please, tell me.



decsoft

Hello again,

I want to continue with our possible JSON interaction, however, if you update App Builder, you can view two new actions: "LoadVariables" and "ParseVariables". This action can be used to load variables from app or remote files in an easy way. Take a look at the action's help and don't forget to play with the new "LoadVars" and "ParseVars" app samples.

Probably you can achieve what you wanted using one of these actions Walter.



Walter Hiller

Hello David,
thank you very much, you´re the best. Both new actions are perfect and help a lot. And yes RANDOM action is ment as you described it as a random number. Thanks again and take care of your health!

kind regards,
Walter


decsoft

Hello Walter,

Thanks very much. Right now I add two new actions into the Math category: "Random" and "RandomEx". The first one provide us with a random number from zero to 1^10 inclusives. The second one provide us with a random number from the specified min and max numbers inclusives.


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.