NSJSONSerialization 转换时 类型注意


进行JSON转化的时候,需要满足一下的要求。


An object that may be converted to JSON must have the following properties:

  • The top level object is an NSArray or NSDictionary.
  • All objects are instances of NSString,NSNumber,NSArray,NSDictionary,or NSNull.
  • All dictionary keys are instances of NSString.
  • Numbers are not NaN or infinity.

也就是说,
  1. 最上面层,必须是 NSArray 或 NSDictionary
  2. 所有的value 必须是 NSString,NSNubmer,NSDictionar 或 NSNull.
  3. 所有的key 必须是 NSString
  4. 并且Numbers 不能是 NaN 或 无穷大。

相关文章

文章浏览阅读2.4k次。最近要优化cesium里的热力图效果,浏览...
文章浏览阅读1.2w次,点赞3次,收藏19次。在 Python中读取 j...
文章浏览阅读1.4k次。首字母缩略词 API 代表应用程序编程接口...
文章浏览阅读802次,点赞10次,收藏10次。解决一个JSON反序列...
文章浏览阅读882次。Unity Json和Xml的序列化和反序列化_uni...