Bean conversion - Multidimensional array

Help
Breno
2013-02-26
2013-04-29
  • Breno
    Breno
    2013-02-26

    Hi!

    I'm having the following issue with my code:

    I'm consuming a big JSON and trying to serialize it as an object. So I created the beans, in which one of them is called 'Result'.  The problem is that 'Result' has a 'data' key that have the following structure:

    "data": [[["2013-01-25 00:00",
    null],
    ["3GCU19647",
    null],
    [1.44035028213746,
    null]],
    [["2013-01-25 00:00",
    null],
    ["3GCU19646",
    null],
    [0.94614369677342,
    null]]]

    As you can see, it's a multidimensional array. So  im my Result.java I added a List data;  but when I'm trying to transform the json to bean object I'm getting an Exception (Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: [Lcom.json.output.Result;.<init>())

    The code I'm using to deserialize:

    JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(json); 
    JsonConfig jsonConfig = new JsonConfig(); 
    jsonConfig.setRootClass(DataObject.class);
    DataObject data = (DataObject) JSONObject.toBean(jsonObject, DataObject.class);

    where DataObject is a root object, which contains Result objects.

    What  I'm doing wrong?

    Thank you very much!