How can I check if a value is a json object?

后端 未结 13 1464
-上瘾入骨i
-上瘾入骨i 2020-11-30 23:33

My server side code returns a value which is a json object on success and a string \'false\' on failure. Now how can I check whether the returned value is a json object?

13条回答
  •  被撕碎了的回忆
    2020-11-30 23:51

    You should return json always, but change its status, or in following example the ResponseCode property:

    if(callbackResults.ResponseCode!="200"){
        /* Some error, you can add a message too */
    } else {
        /* All fine, proceed with code */
    };
    

提交回复
热议问题