I am using REST API to for getting data from SharePoint.

I have one list like category with three column Title and two lookup name like childcategory, parentcategory.

I have some data in which there is no value in both lookup child and parent category.

now I fire query to fetch data expanding lookup value with its Title and ID.

so I'm getting data but in some data of lookup where I didn't get any key value for expanded title and ID

Response I get like below :


and in some row have data in lookup that data in response look like this:


so now how can I parse this json.??

because if I am trying to get Value using Key like Title. so it give JSONException because in some data it don't have that key like first which I have posted response.

How to solve this problem?

Any help greatly appreciated.

3 Answers 3


It seems ChildCategory and SubCategory are not required column. So at the time of parsing your JSON, you need a condition.

if(ChildCategory.Title && ChildCategory.ID){


Another option can be $filter. Just $filter null values for ID and Title so that they do not appear in the result.

&$filter=ChildCategory/Title ne null and ChildCategory/ID ne null
  • sir in json parsing if i am trying to getString using Title. then it give exception for it.if there is not value for title in subcategory. i have one solution to handle that exception .but without it. there is any option in sharepoint if lookup column null then i get value like title="null" ID="null" which we get when text column null. same is possible in lookup.? Commented Jul 25, 2016 at 7:04
  • 1
    Even in Android development you should not, never, nimmer, nooit parse JSON results as if they are Strings. Learn about JSON.parse and hasOwnProperty. Atish his answer works because checking for a non-existing property returns undefined, which is a FALSE value. Commented Jul 25, 2016 at 7:06
  • There is no way to get values like title="null" ID="null". It's better to use $filter for null values. That means null values will not appear in the result. Commented Jul 25, 2016 at 7:07
  • @AtishDipongkor i want that record title if there lookup null then Commented Jul 25, 2016 at 8:59
  • Then you have to consider condition. Another question. What are you using to parse JSON javascript or JAVA? @AndroidDeveloper Commented Jul 25, 2016 at 9:02

I am checked using JsonObject.has("KeyName") it return boolean.

its give true if object contain that keyvalue.

so using this method you can make your logic.

Thank you very much for reply.


I had a similar issue when checking a person field to see it was not empty. Looking for Title didn't work for me. I tried to see if "__deferred" didn't exist and that DID work. Once I getting it working, I don't ask why and just move on. I'll leave that to someone smarter than me.

if (!(ChildCategory.hasOwnProperty('__deferred'))) { 
    alert('result is not empty');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.