Skip to content

Challenge in accessing the JSON Array elements #2460

Answered by gregmarr
augik asked this question in Q&A
Discussion options

You must be logged in to vote

You are not doing any array indexing here. That results in you trying to access the first element of an array using the index "Sign". You want j[0]["Sign"].

You would then be trying to access another array using the index "Status_all". You thus want j[0]["Sign"][0]["Status_all"].

Then again an array using the index "Status1". If you add a [0] before that to give j[0]["Sign"][0]["Status_all"][0]["Status1"], then you are going to iterate over the string "enable", and assigning the characters in that string to x.

I'm not sure what information exactly you are trying to get out of this, and if the JSON contents are fixed, or if you can remove some of those arrays. Hope this helps you figure ou…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@augik
Comment options

Answer selected by augik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants