NSJSONSerialization 转换时 类型注意

来源:互联网 发布:nginx error.log 分析 编辑:程序博客网 时间:2024/06/05 03:41


  

进行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, NSArray, NSDictionar 或 NSNull.
  3. 所有的key 必须是 NSString
  4. 并且Numbers 不能是  NaN 或  无穷大。
0 0
原创粉丝点击