Hi David,
I have a JSON file, with some data like below sample.
How can I load the text of "texto" if "libro" = Juan (or "libro" = Pedro, or "libro" = Lucas)?
I want to show the data in a Table control.
Many thanks in advance.
Hi David,
I have a JSON file, with some data like below sample.
How can I load the text of "texto" if "libro" = Juan (or "libro" = Pedro, or "libro" = Lucas)?
I want to show the data in a Table control.
Many thanks in advance.
Hola Asley,
Maybe some further details can be needed. Supose we want to made a "filter" in the client side, and, the next code is placed inside the "Done" event of an "HttpClient" control, which serve the JSON to us, that is, the "HttpClient" response is the JSON that you shown as a sample.
As you can see, what we do is to initialize the "data" property of a "Table" control. Then we iterate over the "HttpClient" response, in other words, we iterate the JSON registries. As you can see, it's easy to find if the "libro" property of the iterated record / registry is one of the books that we want to show in the "Table" control, and, if so, we add that record / registry to the "date" property of the "Table" control, in order to be shown.
Note that, if the database is in the server side, the same operation can be done in the server side, that is, we ask to the server for some "books name" records, using the appropriate URL, for example: "https://www.appserver.com/items?books=1,2,3" (supose this 1, 2, 3, are the IDs of the required "books" in the database) so the server can prepare the right JSON output, so we no need to perform the filter in the client side, even when, as you can see, it's also possible.
Don't hesitate to ask if you have any further question around this, Asley.
Hello Asley,
Yes; it's possible to filter / delete records from the JSON source, for example:
Note, however, that we modify the original JSON source variable, so, we cannot get the deleted record back. But please, go ahead if you have any further question!
Hola Asley,
Nope. If we have problems with the array deletion... we must prepare a different array, that is, modify the code to something like the below:
That is, what we do above is to prepare a new Array variable ("output") with all the "source" array items, except the items with "ID=2". So you can use then the "output" Array instead of the "source" one.
I did some changes and works great!
Thanks, David.
No problem, Asley! Don't hesitate to post here or in other thread if you have any further questions.
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.