0

I have a json file that contains a nested array of values:

[
    {"target": "dsdsa", 
     "datapoints": 
        [
            [94.283, 1435080720], 
            [94.233, 1435080780], 
            ....
        ]
     }
]

I'm having problem parsing inner nested arrays. I'm using Spring and Jackson. I first parse the outer array using:

Output[] allJson = restTemplate.getForObject("json/url",Output[].class);

where Output is a POJO:

public class Output
{
    public String target;
    //public Datapoint[] datapoints;
}   

public class Datapoint 
{
    private double[] points;
}

Using this I can access the "target" from the json. But if I uncomment it, Jackson is not able to map the array of array of values to the Datapoints.

Do I need another wrapper class? I couldn't find any example where inside the array there is anything except json objects and Jackson parses it.

1 Answer 1

0

[94.283, 1435080720] inside datapoints is not a json object but it's a json list. You will have to use two dimentional array or a list within a list for datapoints. Use

public double[][] datapoints; or List<List<Double>> datapoints

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.