- This topic has 17 replies, 9 voices, and was last updated 6 months ago by kdv.
2021-03-19 at 3:45 pm #39592Jakob KolmanicParticipant
can someone please tell me how to read Values from a Json file ond save the values in variables?
I have a json file like on the first picture and i want to import the values into my project and save the values into variables.
Can someone please tell me the correct way?
thank you!2021-03-20 at 12:37 pm #39607
you can use these puzzles:
https://www.soft8soft.com/docs/manual/en/puzzles/Advanced.html#read_JSON2021-03-20 at 9:27 pm #39609jemCustomer
I have to do this on every project, so I will share the technique I use. Use the puzzles that Yuri pointed out, but here are a few tips.
1. The “load data” puzzle is asynchronous. Don’t assume your data is loaded on the first frame. Use the “once ready do” slot to initiate whatever actions you need to perform.
2. Check if a key is in a dictionary before using it. See puzzle screenshot. Catch the error and do something if the key is missing. Typos and other data errors happen.
3. The dictionary data type in the puzzle system is implemented as a JS object. So if your JSON has nested JS objects, you will need to use the dictionary puzzles to pick through the JSON. See color values in the puzzle screenshot.
Jeremy Wernick2021-03-21 at 8:29 pm #39630karonteCustomer
thanks for your contribution!
MR2021-03-22 at 8:44 am #39634Jakob KolmanicParticipant
Thank you!2021-03-23 at 8:01 am #39674razvan8xParticipant
How can I read a subset of json listed? See the picture. I get false when I check the Ford string.
For example the value of car1?
Thank you!2021-03-23 at 8:30 am #396812021-03-30 at 7:10 am #39838GLiFTeKCustomer
I think something similar to what Jem has shown should be added to the get JSON puzzle user manual entry.
Just a thought.
Powerful puzzle. Needs some elaborating I think.
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2022-11-23 at 11:32 am #58365
Thanks for the information!
Unfortunately I can’t get it to work as I needed.
Even if I simply try to read the loaded data I get an error in the console “Read JSON Puzzle: could not interpret data.” I don’t get it as the JSON I think is the same as in the example of Jem, just with strings.
I added my current puzzles in the attachment, pretty sure it would not work that way.
What I want to archive:
I have a JSON-File where IDs and corresponding RGB-color values are stored.
In my parent HTML UI document there are buttons with the IDs of the JSON.
When one of those buttons is clicked, I want to have the color of one material changed to the corresponding RGB-color value.
How to do that?
I also did post my question in this topic, but I guess it makes more sense here:2022-11-24 at 11:45 am #583992022-11-24 at 11:53 am #58400
Just sent you an email because of the “Read JSON Puzzle: could not interpret data.” error.
I get this error also in an empty project, where I try to load the data.json file which is used by jem in his tutorial.
Thank You for looking into this!2022-11-24 at 12:15 pm #584032022-11-24 at 1:20 pm #58408
Thank you for the fast response and the helpful tip. Currently debugging and trying different puzzle/approaches to get my functionality working. Still struggling.
Would be grateful for any input on how this would work.2022-11-24 at 4:53 pm #58415kdvParticipant
read any .gltf file (in fact, it has the JSON format). see the result. does it work with your set of puzzles?
read this https://www.soft8soft.com/topic/verge3d-4-1-1-maintenance-update/#post-554772022-12-05 at 6:17 pm #58851jakobCustomer
I have the problem that after the update to 4.2 my puzzle logic for importing and reading a json-file via a rest API does not work anymore.
The solution described above that you no longer need a “read json” puzzle I have already adapted.
It all works when I load a local jason-file, but as soon as I want to load the json-file via a REST_API I get an error message (see photo). I think it has something to do with the response of the server.
Would be very happy if someone has a solution.
Link to the REST API with the json file:
Thanks a lot and best regards
- You must be logged in to reply to this topic.