Tagged: json
- This topic has 17 replies, 9 voices, and was last updated 1 year, 11 months ago by kdv.
-
AuthorPosts
-
2021-03-19 at 3:45 pm #39592Jakob KolmanicParticipant
Hello,
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!
Attachments:
You must be logged in to view attached files.2021-03-20 at 12:37 pm #39607Yuri KovelenovStaff2021-03-20 at 9:27 pm #39609jemCustomerHi Jokob,
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.
Attachments:
You must be logged in to view attached files.Jeremy Wernick
2021-03-21 at 8:29 pm #39630karonteCustomerthanks for your contribution!
MR
2021-03-22 at 8:44 am #39634Jakob KolmanicParticipantThank you!
2021-03-23 at 8:01 am #39674razvan8xParticipantHi Yuri,
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?
{
“name”:”John”,
“age”:30,
“cars”: {
“car1″:”Ford”,
“car2″:”BMW”,
“car3″:”Fiat”
}
}Thank you!
Attachments:
You must be logged in to view attached files.2021-03-23 at 8:30 am #39681Yuri KovelenovStaff2021-03-30 at 7:10 am #39838GLiFTeKCustomerI 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 #58365fred7CustomerHello,
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?
Thank You!
I also did post my question in this topic, but I guess it makes more sense here:
Attachments:
You must be logged in to view attached files.2022-11-24 at 11:45 am #58399Yuri KovelenovStaff2022-11-24 at 11:53 am #58400fred7CustomerJust 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 #58403Yuri KovelenovStaff2022-11-24 at 1:20 pm #58408fred7CustomerThank 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 #58415kdvParticipantread 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-55477
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2022-12-05 at 6:17 pm #58851jakobCustomerHello,
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:
https://hook.eu1.make.com/qbgjk8a1f52jbwmv1qv95hz126c8j9dyThanks a lot and best regards
jakobAttachments:
You must be logged in to view attached files. -
AuthorPosts
- You must be logged in to reply to this topic.