isValidJSONObject not working as expected

后端 未结 1 1488
心在旅途
心在旅途 2020-12-06 17:44

After testing, I can only get [NSJSONSerialization isValidJSONObject:] to return a positive on JSON data that I have already parsed with [NSJSONSerializat

相关标签:
1条回答
  • 2020-12-06 18:26

    isValidJSONObject tests if a JSON object (a NSDictionary or NSArray) can be successfully converted to JSON data.

    It is not for testing if an NSData object contains valid JSON data. To test for valid JSON data you just call

    [NSJSONSerialization JSONObjectWithData:data ...]
    

    and check if the return value is nil or not.

    0 讨论(0)
提交回复
热议问题