猎豆优选

TBSDKJSONBridge.h 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // '########'########::'######:'########:'##:::'##:
  2. // ... ##..::##.... ##'##... ##:##.... ##:##::'##::
  3. // ::: ##::::##:::: ##:##:::..::##:::: ##:##:'##:::
  4. // ::: ##::::########:. ######::##:::: ##:#####::::
  5. // ::: ##::::##.... ##:..... ##:##:::: ##:##. ##:::
  6. // ::: ##::::##:::: ##'##::: ##:##:::: ##:##:. ##::
  7. // ::: ##::::########:. ######::########::##::. ##:
  8. // :::..::::........:::......::........::..::::..::
  9. //
  10. // Created by Robert on 13-1-21.
  11. // Copyright (c) 2013年 Taobao. All rights reserved.
  12. //
  13. #import <Foundation/Foundation.h>
  14. ////////////
  15. #pragma mark Deserializing methods
  16. ////////////
  17. @interface NSString (MTOPJSONDeserializing)
  18. - (id)mtopObjectFromJSONString;
  19. - (id)mtopMutableObjectFromJSONString;
  20. @end
  21. @interface NSData (MTOPJSONDeserializing)
  22. // The NSData MUST be UTF8 encoded JSON.
  23. - (id)mtopObjectFromJSONData;
  24. - (id)mtopMutableObjectFromJSONData;
  25. @end
  26. ////////////
  27. #pragma mark Serializing methods
  28. ////////////
  29. @interface NSString (MTOPJSONSerializing)
  30. // Convenience methods for those that need to serialize the receiving NSString (i.e., instead of having to serialize a NSArray with a single NSString, you can "serialize to JSON" just the NSString).
  31. // Normally, a string that is serialized to JSON has quotation marks surrounding it, which you may or may not want when serializing a single string, and can be controlled with includeQuotes:
  32. // includeQuotes:YES `a "test"...` -> `"a \"test\"..."`
  33. // includeQuotes:NO `a "test"...` -> `a \"test\"...`
  34. - (NSData *)mtopJSONData; // Invokes JSONDataWithOptions:JKSerializeOptionNone includeQuotes:YES
  35. - (NSString *)mtopJSONString; // Invokes JSONStringWithOptions:JKSerializeOptionNone includeQuotes:YES
  36. @end
  37. @interface NSArray (MTOPSONSerializing)
  38. - (NSData *)mtopJSONData;
  39. - (NSString *)mtopJSONString;
  40. @end
  41. @interface NSDictionary (MTOPJSONSerializing)
  42. - (NSData *)mtopJSONData;
  43. - (NSString *)mtopJSONString;
  44. @end
  45. @interface NSNumber (MTOPJSONSerializing)
  46. - (NSData *)mtopJSONData;
  47. - (NSString *)mtopJSONString;
  48. @end