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;

      result = query("SELECT {Lead:Name}, {Lead:Company} FROM {Lead}");

      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);

        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?

  • Is this related to Salesforce? There may be a better forum for this question.
    – Doug B
    Commented Jun 12, 2015 at 9:28
  • Looks to be using the SF mobile SDK. Commented Jun 12, 2015 at 9:37

1 Answer 1


Based on the syntax table in the Mobile SDK docs, try changing your smartSql to:

result = query("SELECT {Lead:_soup} FROM {Lead}");

Note that this should return the entire JSON Lead object, and not an object with only specific fields. I don't believe you can return arbitrary JSON objects containing only certain field from the originally stored object(s).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .