#Getting info from json and showing it on ui

1 messages · Page 1 of 1 (latest)

terse trench
#

So i am trying to retrieve data from a json file, and instantiate cubes at the positions given in the json file. But getting error while parsing the vec.

cold drift
#

obviously you are passing in a Vector2 string not a Vector3 string

warped cobalt
#

Why are you parsing strings yourself directly? The built in json methods do all of this for you

terse trench
#

The thing is, i need to read both vec2 and vec3 values

cold drift
cloud swallowBOT
terse trench
#

how can i post the json file?

cold drift
terse trench
#

i feel the issue is with the json file

cold drift
warped cobalt
#

The issue is that you are storing everything as strings

terse trench
cold drift
#

"pin_position": "97.31, -47.31",
WHY ?????

terse trench
#

so its wrong right?

#

the json file i mean

cold drift
#

its a string containing 2 floats. it's not even a json object

terse trench
#

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

warped cobalt
#

You didnt make the json file?

cold drift
#

compare with
"location": "(7.04, 2.25, 0.68)",

terse trench
#

no

#

this is what they requested me to do.

cold drift
#

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

terse trench
warped cobalt
# terse trench no

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

warped cobalt
warped cobalt
#

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