Reputation: 1201
Having a simple json:
{ "Keys": [
{"Format": "A", "Subtype": "A1"},
{"Format": "A", "Subtype": "A2"},
{"Format": "B", "Subtype": "A1"}]
}
I would like to generate this result (Format + Subtype concatenation) using JsonPath expressions (without Java specific implementation):
AA1
AA2
BA1
Is it possible to concatenate the string elements using jsonPath?
Thank you
Upvotes: 5
Views: 19325
Reputation: 49
The following would give AA1
as a result.
$.concat($.Keys[0].Format,$.Keys[0].Subtype)
Similarly
$.concat($.Keys[1].Format,$.Keys[1].Subtype) -- AA2
$.concat($.Keys[2].Format,$.Keys[2].Subtype) -- BA1
Upvotes: 3
Reputation: 11
I know this post was a while ago but I'm searching for similar problems. Isn't this the solution?
$.Keys[0].Format$.Keys[0].Subtype
$.Keys[1].Format$.Keys[1].Subtype
$.Keys[2].Format$.Keys[2].Subtype
Upvotes: 1
Reputation: 923
You can frame JSON path expressions like:
$.Keys[0].Format -- A
$.Keys[1].Format -- A
$.Keys[2].Format -- B
and refer to this SO thread the below link to eventually parse it using Jayway.
Upvotes: 0