mardi 30 juin 2015

Good way to store many nested JSON objects and arrays as data structure in Android SQLite?

Considering the below JSON, what would be the best way to store this into SQLite?

I am already parsing this with Gson, but wondering what would be a pain-free way to store this into SQLite and be able to retrieve it with no parsing issues.

I am already storing the desc, deposit objects as a HashMaps. My issue is the lease object. What would be an elegant way to store the leasees array?

Should I just create another Leasee object? And then serialize the ArrayList into a Blob for storage into the database?

{
  "name": "1",
  "desc": {
    "country": "1",
    "city": "1",
    "postal": "1",
    "street": "1",
    "substreet": "1",
    "year": 1,
    "sqm": 1
  },
  "owner": [
    "1"
  ],
  "manager": [
    "1"
  ],
  "lease": {
    "leasee": [
      {
        "userId": "1",
        "start": {
          "$date": 1420070400000
        },
        "end": {
          "$date": 1420070400000
        }
      }
    ],
    "expire": {
      "$date": 1420070400000
    },
    "percentIncrease": 1,
    "dueDate": 1
  },
  "deposit": {
    "bank": "China Construction Bank",
    "description": "Personal Bank Account USA"
  }
}

Aucun commentaire:

Enregistrer un commentaire