#Getting info from json and showing it on ui
1 messages · Page 1 of 1 (latest)
obviously you are passing in a Vector2 string not a Vector3 string
Why are you parsing strings yourself directly? The built in json methods do all of this for you
here is the script if it helps.
The thing is, i need to read both vec2 and vec3 values
Please !code, you should know this by now
📃 Large Code Blocks
Use links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/, https://paste.myst.rs/, https://hastebin.com/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
then handle both cases
i feel the issue is with the json file
also in a paste site
The issue is that you are storing everything as strings
this is the json.
"pin_position": "97.31, -47.31",
WHY ?????
its a string containing 2 floats. it's not even a json object
I knew the assignment was wrong. I was given this test for a job. but keep getting error at that line. knew the json wasnt correct
You didnt make the json file?
compare with
"location": "(7.04, 2.25, 0.68)",
that data is not 'wrong' the way you are trying to interpret is very wrong
tbh the first thing you should have done is look at the json data and make one or more c# classes to mirror the structure
ok. give me a 1min. will do it
I asked if you made because that wouldve meant you had all the types available. But also you shouldnt need to do any string parsing yourself. The whole json deserialize methods should take care of that for you
These shouldn't all be strings..
https://docs.unity3d.com/ScriptReference/JsonUtility.FromJson.html
Look at the example here
changed it
Are you testing these codes before sending them?
I recommend trying with your own class and a smaller example if you can. Try making your own json with only a few values, and see what the result is. Then try reading it back. The large file is probably a bit overwhelming