0

Is there a way to de-serialize and serialize this style of Json object?

"values":[
                     [
                        "2014-06-01T00:10:00+02:00",
                        "0.000000"
                     ],
                     [
                        "2014-06-01T00:20:00+02:00",
                        "0.000000"
                     ],
                     [
                        "2014-06-01T00:30:00+02:00",
                        "0.000000"
                     ],

In my case, I'm planning on using a List values, Value being a class that only stores an array/list which only stores two values (time, a float) but I'm OK with both being Strings.

The class Value would use the toJson() and fromJson() methods to accomplish the deserialization and serialization.

@Override
public JsonObject toJson() {
    // TODO Auto-generated method stub
    JsonObject json = new JsonObject();
    Gson gson = new GsonBuilder().create();

    gson.toJson(this.getValue(), String[].class);

    return json;
}

But how do I return the JsonObject?? I can't add it to json using add methods because I don't need to add a property. What could I do else?

EDIT: I'm looking for a way to add the gson.toJson to json object. It's not necessarily a duplicate question without adding a key for it.

Geosphere
  • 315
  • 4
  • 15

0 Answers0