• 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: Checking if a string is valid JSON
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking if a string is valid JSON


  • Subject: Re: Checking if a string is valid JSON
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 29 Jan 2018 13:48:17 -0800

On Jan 29, 2018, at 13:30 , Saagar Jha <email@hidden> wrote:
>
> Uhh…JSONDecoder swallows all of JSONSerialization’s errors and wraps it into
> its own
> <https://github.com/apple/swift/blob/e5fdc0955ce662bd929c7e1706d4a1f1d0f5d397/stdlib/public/SDK/Foundation/JSONEncoder.swift#L1097>.
>  I’m not sure this counts as “more detailed”.

Well, it presents all of JSONSerialization’s errors as DecodingError, but these
are not all the DecodingErrors it can present. Also, AFAICT from a brief look
at that code, DecodingError has a “codingPath” value that apparently locates
the error within the source string. That seems unique to JSONDecoder.

OTOH, it may be that JSONSerialization errors are in fact as informative as
JSONDecoder errors, in which case I mostly retract my comment. (I still think
JSONDecoder is a better choice.)

_______________________________________________

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

References: 
 >Checking if a string is valid JSON (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Checking if a string is valid JSON (From: Saagar Jha <email@hidden>)
 >Re: Checking if a string is valid JSON (From: "Eric E. Dolecki" <email@hidden>)
 >Re: Checking if a string is valid JSON (From: Quincey Morris <email@hidden>)
 >Re: Checking if a string is valid JSON (From: Saagar Jha <email@hidden>)

  • Prev by Date: Re: Checking if a string is valid JSON
  • Previous by thread: Re: Checking if a string is valid JSON
  • Next by thread: Re: Checking if a string is valid JSON
  • Index(es):
    • Date
    • Thread