In Tutorial 4, Store Search example processes JSON data from iTune using method, JSONSerialization.jsonObject(with:, options:). Two questions:
- For the option parameter, the code used []. What does that indicate? Noticed other examples on Ray Wenderlich site used JSONSerialization.ReadingOptions(rawValue: 0). What other options could we use and what are the differences? Searched Apple online help but didn’t find useful info.
- Looked into the data returned by JSONSerialization.jjsonObject(with:, options:). For an ebook it has a genres component in the format of genres = ( History, “Arts & Entertainment”, Photography, … ); Is ( ) the Swift’s way noting an array in a dictionary?
Many thanks.
Many thank for your response, narrativium!
- What option to use in NSJSONSerialization.ReadingOptions() would depend on the options used on the feeding side of the data. Probably most of the time no option would be the case. Just wondering when we would use options other than [ ] to serve a purpose in the context of NSJSONSerialization. Obviously this would start from NSJSONSerialization.WritingOptions().
- I agree that the ( ) notation for array in the parsed jsonDictionary is due to the print statement of Swift. It’s not defined in json notation and doesn’t seem injected in JSONSerialization.ReadingOptions(), https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSJSONSerialization.swift
Thanks, Again.