google app engine - Store java.util.List into GAE Datastore -
this idea of storing json , json-like documents "natively" gae datastore:
protected void createentity(key parent, map obj){ try { entity e = new entity( parent == null ? createkey(_kind, (string) obj.get(object_id)) : parent); iterator = obj.keyset().iterator(); while (it.hasnext()){ string key = (string) it.next(); if (obj.get(key) == null){ e.setproperty(key, null); } else if (obj.get(key) instanceof string) { setproperty(e, key, obj.get(key)); } else if(obj.get(key) instanceof number) { setproperty(e, key, obj.get(key)); } else if(obj.get(key) instanceof boolean) { setproperty(e, key, obj.get(key)); } else if(obj.get(key) instanceof list) { // problem area, right way store list? // list may contain jsonobject too! } else if(obj.get(key) instanceof map){ // update: ooops, cause stackoverflow error! key pkey = createkey(e.getkey(), _kind, (string) obj.get(key)); e.setproperty(key, pkey.tostring()); // not sure? createentity(pkey, obj); } } _ds.put(e); } catch (concurrentmodificationexception e){ } catch (exception e) { // todo: handle exception } }
the approach recursive put, gae supported non-collection properties stored directly entity's property. map
s new entity created parent key having current entity key, , forth.
the basis of supported types of json interface this: http://code.google.com/p/json-simple/
the problem have i'm not sure how deal java.util.list
, , how store maybe in manner map.
any suggestion on how achieve this?