mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-06 17:12:50 +00:00
Simpler JSON APIs as CPString class/instance methods.
Signed-off-by: Tom Robinson <yachttom@gmail.com>
This commit is contained in:
1 parent
c6529f6bf7
commit
b3c71fef9e
1 file changed
+21
@@ -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;
|
||||
Reference in new issue
Block a user