Uploaded image for project: 'Swift'
  1. Swift
  2. SR-6163

JSONDecoder cannot decode RFC 7159 JSON

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Foundation
    • Labels:

      Description

      For example

      22
      

      Is valid RFC 7159 JSON. This can be parsed using the JSONSerializer like so

      let json = "22".data(using: .utf8)!
      
      if let value = (try? JSONSerialization.jsonObject(with: json, options: .allowFragments)) as? Int {
          print(value) // 22
      }
      

      But there is no way to use the allowFragments option for JSONDecoder.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              itaiferber Itai Ferber
              Reporter:
              mikkelam mikkel madsen
              Votes:
              23 Vote for this issue
              Watchers:
              23 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: