Simpler JSON APIs as CPString class/instance methods.

Signed-off-by: Tom Robinson <yachttom@gmail.com>
This commit is contained in:
Tom Robinson authored and Tom Robinson committed 2009-01-07 15:27:24 +08:00
1 parent c6529f6bf7
commit b3c71fef9e
1 file changed
+21
+21
View File
@@ -23,6 +23,7 @@
@import "CPObject.j"
@import "CPException.j"
@import "CPSortDescriptor.j"
@import "CPValue.j"
/*!
@@ -640,4 +641,24 @@ var CPStringHashes = new objj_dictionary();
@end
@implementation CPString (JSON)
/*!
Returns a string representing the supplied JavaScript object encoded as JSON.
*/
+ (CPString)encodeJSON:(JSObject)anObject
{
return CPJSObjectCreateJSON(anObject);
}
/*!
Returns a JavaScript object decoded from the string's JSON representation.
*/
- (JSObject)decodeJSON
{
return CPJSObjectCreateWithJSON(self);
}
@end
String.prototype.isa = CPString;