Skip to content

iterate []x.json2.Any #23567

Discussion options

You must be logged in to vote

We learn a lot reading also the tests: https://github.com/vlang/v/blob/master/vlib/x/json2/tests/decoder_test.v

import x.json2

raw_mp := json2.raw_decode('[
	{"name":"Paul","last_name":"McCartney"},
	{"name":"John","last_name":"Lennon"}]
')!
contacts := raw_mp.as_map()
for _, v in contacts {
	contact := v.as_map()
	println('${contact["last_name"]}')
}
McCartney
Lennon

See https://play.vlang.io/p/ce463d8242

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Brixy
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants