How to get and judge a Boolean value in JSON

Source: Internet
Author: User

I actually know that the data returned is a Boolean type,

It's just that when you make a judgment, you find direct use

if([responseobjectobjectforkey:@ "Success"]) judgment does not make any sense, Because I'm judging that this is not true, in other words, is not a non-empty,

Oh, no, of course not. Returns a false but that is also worthwhile, so, I try to use change data type to receive,

When I use NSString * to receive,

This error occurs

[__Nscfboolean isequaltostring:]: Unrecognized selector sent to instance

OMG, well, he's really not a string type, he's a Boolean,

Then try to use [[Responseobject objectforkey:@ "Success"] boolvalue];

Don't ask me why I don't receive it directly with BOOL because there's a damn warning.

I'm sorry I'm a little excited.

Well, now sum it up:

It is estimated that the number of ID types that iOS receives by default is NSNumber type, so value is needed here,

Oh, yes, if it's post, all the data is really nsnumber, so the data that JSON receives and sends is really the NSNumber class.

That made sense.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.