NSObject+AGSSBJson.h has been removed from v100 ??
how can we use ags_JSONRepresentation ??
SBJson was a third party library that has no longer been necessary the last few years now that Apple has shipped NSJSONSerialization. Objects that support AGSJSONSerializable have a toJSON method you can call. That will give you a JSON object (most likely an NSDictionary, but could be an NSArray). You can use that JSON object with NSJSONSerialization to get NSData:
AGSObject -> NSDictionary -> NSJSONSerialization -> NSData
You can also go the other way if you have NSData:
NSData -> NSJSONSerialization -> NSDictionary -> AGSObject
Here is sample code showing you how to do both:
-(void)testJSONSerialization{
// Example 1: AGSPoint to NSData of JSON string...
//
AGSPoint *point = [AGSPoint pointWithX:34 y:-117 spatialReference:[AGSSpatialReference WGS84]];
id jsonObject = [point toJSON:nil];
NSData *data = [NSJSONSerialization dataWithJSONObject:jsonObject options:0 error:nil];
// do whatever you want with the NSData...
// ...
// ...
// For example print out a json string:
NSLog(@"the json string: %@", [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
// Example 2: NSData of JSON String to AGSPoint
//
id jsonObject2 = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
AGSPoint *point2 = (AGSPoint*)[AGSPoint fromJSON:jsonObject2 error:nil];
// print out and test for equality
NSLog(@"point1: %@", point);
NSLog(@"point2: %@", point2);
NSAssert([point isEqualToGeometry:point2], @"point comparison failed...");
}
Thank you so much