How to retrieve values from nested json structures (Maps)

json

#23

And again, open the values…

(I think it clear, the parser is happy (so far, anyway))


#24

image


#25

hey, now i see it. that key is not directly at the root of parsedJson but few levels deep, in data.blah


#26

Ha!

NOW you’re on target!


#27

@Russ_Thomas sorry,boss. from the dumbphone the debug is hard.but there is the key, the variable should be properly traversed to reach the right key


#28

so, I’m not nearly as technical as all that…something like

parsedJson.data[0].biometricsEnabled ?


#29

@Amanda_Perkins1 yah. sort of. you have to reach that key at the right position. sorry, i am from the phone so is hard to post a working code, but you got the picture


#30

Yep. I’d try that or something similar. I don’t do enough map-delving to keep it in my head. :frowning:


#31

maping is always confusing … i’ve been hit many times


#32

well, now it just hates me because java.lang.String cannot be cast to java.lang.Integer


#33

You might try tinkering with this:

Map data = parsedJson.data // or parsedJson["data"]
boolean thing = data["biometricsEnabled"] // or whatever

Or did I miss a step there… I think you see where this is going though.


#34

THAT WORKED!!!

OMG!! Thanks Guys!!


#35

one step at a time :)))
hidden may be tha path of maps …


#36

Well, it worked for that particular one, yes. Now, to see if I can figure out another one that’s in a different level…

mwahahaha


#37

at least, now you know how to debug it :slight_smile:


#38

Good point.

@Amanda_Perkins1 It’s a good idea (esp. with awkward stuff like this) to review your work in the debugger: “Is this really doing what I think it’s doing?”


#39

Absolutely. So, I learned at least 3 new things today. And that’s going to come in handy later!!


#40
  1. Russ is a pedantic old fool.
  2. Ibus can’t type for shit on his phone.
  3. Amanda is way more techie than she thought she was.

Your work here is done, I think :wink: