stackmob - how to parse SMValue to String array -
i getting familiar stackmob server side custom code sdk , trying relationship field , iterate through in form of string array. how do ? possble iterate through without parsing array?
dataservice ds = serviceprovider.getdataservice(); list<smcondition> query = new arraylist<smcondition>(); query.add(new smequals("product_id", new smstring(jsonobj.getstring("product_id")))); list<smobject> results = ds.readobjects("product", query); smobject product= results.get(0); //product.getvalue().get("categories"); how string array?
at simplest, this:
list<smvalue> categories = (list<smvalue>)(rawobj.getvalue().get("categories").getvalue()); (smvalue smstring : categories) { smstring stringvalue = (smstring)smstring.getvalue(); //do whatever want string value here }
obviously there unchecked casts in here, want add type/null checking appropriate sections depending on data & schema.
Comments
Post a Comment