I'm using the SalesforceMobileSDK and I'm having trouble querying my smartstore soup in my native android application. When I query my soup I recieve a JSONArray with JSONArrays in it, while it has to be filled with JSONObjects. I think this is because I'm using the "buildSmartQuerySpec" function from the QuerySpec class.
Is it normal that the "buildSmartQuerySpec" returns a JSONArray with JSONArrays in it, which normally should be a JSONArray with JSONObjects?
This is my function to retrieve a JSONArray filled with the smartstore soup:
public JSONArray fetchOfflineLeads(){
JSONArray result = null;
if(smartStore.hasSoup(LEADS_SOUP)){
result = query("SELECT {Lead:Name}, {Lead:Company} FROM {Lead}");
System.out.println(result);
}else{
System.out.println("there is no soup");
return null;
}
return result;
}
This is my query function :
public JSONArray query(String smartSql){
JSONArray result = null;
QuerySpec querySpec = QuerySpec.buildSmartQuerySpec(smartSql, 10);
int count = smartStore.countQuery(querySpec);
querySpec = QuerySpec.buildSmartQuerySpec(smartSql, count);
try{
result = smartStore.query(querySpec, 0);
}catch(JSONException e){
Log.e(TAG, "Error when trying to run query");
}
return result;
}
I get this when I print my JSONArray out:
[["Bertha Boxer","Farmers Coop. of Florida"],["Phyllis Cotton","Abbott Insurance"],["Jeff Glimpse","Jackson Controls"]]
While it has to be like this:
[{"Name":"Bertha Boxer","Company":"Farmers Coop. of Florida"},{"Name":"Phyllis Cotton","Company""Abbott Insurance"},{"Name":"Jeff Glimpse","Company""Jackson Controls"}]
Someone knows what I'm doing wrong? Is my string with my smartSql not right?