• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JSON validator for Xcode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JSON validator for Xcode


  • Subject: Re: JSON validator for Xcode
  • From: Fritz Anderson <email@hidden>
  • Date: Tue, 06 Mar 2012 14:46:00 -0600

On 6 Mar 2012, at 1:59 PM, Alex Zavatone wrote:

> Yeah, I've got the JSON down to this:
>
> [1]
>
> and
> {"A":1}
>
> And the code:
> BOOL isTurnableToJSON = [NSJSONSerialization isValidJSONObject: responseData];
> 	NSLog(@"Is legit for JSON: %d", isTurnableToJSON );
> 	NSLog(@"Is legit for JSON: %@", isTurnableToJSON ? @"YES" : @"NO"); // this is how we handle a bool :/

Wait — am I to understand you are passing a JSON string to isValidJSONObject:? I can't make sense of your citing JSON strings as problem cases otherwise, but in your original message you talk about _emitting_ JSON.

The method goes the other way around. It determines whether a tree of Foundation objects can be translated _into_ JSON. NSJSONSerialization won't accept anything but container objects, so passing a string won't validate even fortuitously.

The method names are inexpressive.

	— F


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: JSON validator for Xcode
      • From: Alex Zavatone <email@hidden>
References: 
 >JSON validator for Xcode (From: Alex Zavatone <email@hidden>)
 >Re: JSON validator for Xcode (From: Alex Zavatone <email@hidden>)
 >Re: JSON validator for Xcode (From: Fritz Anderson <email@hidden>)
 >Re: JSON validator for Xcode (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Finding object array index when iterating through array
  • Next by Date: Re: JSON validator for Xcode
  • Previous by thread: Re: JSON validator for Xcode
  • Next by thread: Re: JSON validator for Xcode
  • Index(es):
    • Date
    • Thread