Read List<Pair> from JSON with Jackson

Clash Royale CLAN TAG#URR8PPP
Read List<Pair<Double, Double>> from JSON with Jackson
How can I read a List<Pair<Double, Double>> from JSON, using Jackson, into a class instance’s field of type List<Pair<Double, Double>>:
List<Pair<Double, Double>>
List<Pair<Double, Double>>
if(jsonNode.get(“arrayListPair”).isArray())
for (JsonNode objNode: jsonNode.get(“arrayListPair”))
// how to convert objNode to Pair<Double, Double>
Sample, as requested:
"arrayListPair" : [ [1.2, 3.4], [5.6, 7.8] ]
Thanks
Can you provide us your JSON ?
– Emre Savcı
Aug 12 at 8:40
Just added above, thanks
– shanlodh
Aug 12 at 8:43
So, the arrayListPair node is an array node. You need to iterate though its elements (fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/…). For each element, which is also an array, you need to get the node at index 0 and the node at index 1 (fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/…), Then you need to get each of these two values as a double (fasterxml.github.io/jackson-databind/javadoc/2.9/com/fasterxml/…).
– JB Nizet
Aug 12 at 9:00
I've never used that low-level Jackson API, but by reading the javadoc, I can know how to use it. That's why the javadoc exists. Read it.
– JB Nizet
Aug 12 at 9:01
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
We have no idea, because you didn't say what your JSON looked like. We can't read your screen.
– JB Nizet
Aug 12 at 8:38