Unknown property name in JSON
-
I'm back on track with my old friend JSON issue
Is there a way to get the file property without knowing the "unknown" property name?
{ "meta": { "unknown1": { "file": "value1" }, "unknown2": { "file": "value2" } } }
I know there are methods in javascript but it's not the same story with Hise...
I can place the names in an array like so
["unknown1", "unknown2"]
,
but thenmeta.array[i]
obviously won't work more than any iteration method likemeta[i]
oru in meta
@d-healey, I know you made a parser a while ago that is able to find a different number of elements in an object.
Could it be a worthy solution to explore? -
@ustk
Do you mean like this?for (i in json.meta) { var p = json.meta[i]; for (j in p) var v = p[j]; Console.print(v); }
-
@ustk said in Unknown property name in JSON:
@d-healey, I know you made a parser a while ago that is able to find a different number of elements in an object.
I added
String.parseAsJSON()
, is that what you're referring to? I don't think that will be any use here. I'd do what @ulrik suggested. -
@ulrik Thanks a lot! It is so strange because I tried a very similar method for accessing the properties using
[]
with no luck. For some reason I was always returning the name of the key rather han the object itself...
You saved me :)@d-healey I say parser but I reckon it was an object sorter of some kind... @ulrik solution is indeed what I need
Thanks guys!