0

I have json format which I want to create in java code using JSONObject and JSONArray but I did not get output in proper format. JSON format is as below.

var transaction_Data = 
[
    {
    "key": "PASSED",
    "values": [

        {"x": "20 June", "y": 30},
        {"x": "21 June", "y": 50},
        {"x": "22 June", "y": 20},
        {"x": "23 June", "y": 60},
        {"x": "19 June", "y": 20},
        {"x": "24 June", "y": 10}
        ]
    },
    {
    "key": "FAILED",
    "values": [
            {"x": "19 June", "y": 50},
            {"x": "21 June", "y": 30},
            {"x": "20 June", "y": 20},
            {"x": "23 June", "y": 70},
            {"x": "22 June", "y": 45},
            {"x": "24 June", "y": 60}
     ]
   }
]

How can I create this json object in java because I want to use this object for creating multibar graph using NVD3. Any help is greatly appreciated!

ASP
  • 121
  • 1
  • 1
  • 12

1 Answers1

0
you can try it out with this POJOs.

class TransactionData {
    private String key;
    private List<Data> values;
    public TransactionData(String key, List<Data> values) {
        this.key = key;
        this.values = values;
    }
}
class Data {
    private String x;
    private Integer y;
    public Data(String x, Integer y) {
        this.x = x;
        this.y = y;
    }
}
user3531588
  • 114
  • 1
  • 4