Objective-C JSON

Compiler Error with LLVM 5.1 "Deprecated isa"

I am getting compiler errors with libJSONKit and in JSONKit.m. The errors are thrown with this: "Assignment to Objective-C's isa is deprecated in favor of object_setClass()".
There is also a secondary error: "Direct access to Objective-C's isa is deprecated in favor of object_getClass()".

Any advice on workarounds or solutions?

Source: (StackOverflow)

Can't turn off ARC for JSONkit

Using JSONkit for a project that is ARC enabled, and having issues. I flagged the files appropriately as -fno-objc-arc and tried a build, but it is still throwing errors like ARC is enabled. Any ideas what I could be missing?

For clarity, I flagged the file in Build Phases->Compile Sources->JSONkit.m

EDIT: screen shot of the errors. These are the same errors I got before adding the flag for the file to be ignored by ARC enter image description here

Source: (StackOverflow)


Does JSONKit support ARC, or is there a fork that supports ARC?

According to these comments, JSONKit does not support ARC, and not even running with fobjc-no-arc setting in an ARC environment: https://github.com/johnezang/JSONKit/issues/37

Source: (StackOverflow)

iOS 7 : 'isa' is deprecated

I get warning when I run my app in iOS7 "'isa' is deprecated", I don't have any idea how to fix this warning message. Please any one help on this.

array->isa      = _JKArrayClass;

Source: (StackOverflow)

Serializing complex NSObject to JSON pattern

I have a series of NSObject's I would like to serialize to JSON and post to a service. The final object consists of several levels of these NSObject subclasses nested within each other.

Each one of these objects follows a protocol with a method which returns that objects properties in an NSDictionary with the appropriate keys. However, some of these properties are other objects and so forth, making the serialization a bit complicated.

Is there a pattern I could use to simplify serializing the final object? Using JSONKit, it seems I would need to serialize each dictionary individually from the deepest object and work backwards, checking for errors, then adding to a compound string. I know this can not possibly be the best method using this very capable library. Any suggestion or guidance is welcomed.

Edit 1


JSONKit Readme Documentation

Source: (StackOverflow)

-[NSURL _CFURLRequest]: unrecognized selector sent to instance

i am using JSONKit in my program to parse google places api but my app crashes with the following error -[NSURL _CFURLRequest]: unrecognized selector sent to instance

     NSString* URL = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=28.632808,77.218276&radius=500&types=atm&sensor=false&key=AIzaSyDHft2g5IDshIpXS17uOtZzkqGGgj-p1RQ"];

NSError* error = nil;
NSURLResponse* response = nil;

NSURLRequest *URLReq = [NSURL URLWithString:URL];
//[request setURL:URL];
//[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
//[request setTimeoutInterval:30];

NSData* data = [NSURLConnection sendSynchronousRequest:URLReq returningResponse:&response error:&error];

if (error)
    NSLog(@"Error performing request %@", URL);
    NSLog(@"%@", [error localizedDescription]);

NSDictionary *json = [data objectFromJSONData];

NSArray *places = [json objectForKey:@"results"];

NSLog(@"Google Data: %@", places);

Source: (StackOverflow)

Memory leaks JSONKit iOS

I'm using JSONKit in my app, but when I click analyze in Xcode I get 2 issues in JSONKit.m:

Issue 1:

Issue 1

Issue 2:

Issue 2

Should I do something about this?

Source: (StackOverflow)

Duplicate Symbol _OBJC_IVAR_$_GCOAuth.OAuthParameters ShareKit and RestKit.

I am in a sticky situation where for the last couple of days I havent been able to progress with sharekit implementation because I am getting a duplicate symbol error with RestKit. I am running with iOS 5.1 and the latest version of xcode. I have both libraries installed as to the guidelines given. I dont understand how to remove references of this from ShareKit or RestKit without causing problems in one or the other. I really need some help on this one... Thanks.

duplicate symbol _OBJC_IVAR_$_GCOAuth.OAuthParameters in:

my project

Source: (StackOverflow)

JSONKit for xcode 4.6 ios 6 with ARC?

Well, I did add the JSONKit classes (JSONKit.h & JSONKit.h) but in the .m file, I have a lot of warnings & compil's error's like:

NSError *error;  //--> ARC forbids Objetive-C in structs or unions


id key, object; whit the same error

anObject = [anObject retain]; //---> ARC forbids explicit message send 'retain''

or many error's in this part code:

static void _JKArrayInsertObjectAtIndex(JKArray *array, id newObject, NSUInteger objectIndex) {
  NSCParameterAssert((array != NULL) && (array->objects != NULL) && (array->count <= array->capacity) && (objectIndex <= array->count) && (newObject != NULL));
  if(!((array != NULL) && (array->objects != NULL) && (objectIndex <= array->count) && (newObject != NULL))) { [newObject autorelease]; return; }
  if((array->count + 1UL) >= array->capacity) {
    id *newObjects = NULL;
    if((newObjects = (id *)realloc(array->objects, sizeof(id) * (array->capacity + 16UL))) == NULL) { [NSException raise:NSMallocException format:@"Unable to resize objects array."]; }
    array->objects = newObjects;
    array->capacity += 16UL;
    memset(&array->objects[array->count], 0, sizeof(id) * (array->capacity - array->count));
  if((objectIndex + 1UL) < array->count) { memmove(&array->objects[objectIndex + 1UL], &array->objects[objectIndex], sizeof(id) * ((array->count - 1UL) - objectIndex)); array->objects[objectIndex] = NULL; }
  array->objects[objectIndex] = newObject;

how can I use in the best way the JSONKit & JSON framework for xcode 4.6 iOS 6?

& thanks a lot!!! greetings from Bolivia!! Rock ON!!! XD

Source: (StackOverflow)

How to parse the data in JSONKit with following format

I have following data and i want to print the list of items with following structure.

Let me know how can i do that.

I can't get the data using the following syntax.

/* Data to Row Json from URL*/
NSString *MyRowJson = [NSString stringWithContentsOfURL:url
                                               encoding:NSUTF8StringEncoding error:nil]; 

/* Copy data to Items from MyRowJson*/
NSDictionary *items = [MyRowJson objectFromJSONStringWithParseOptions:true];

/*get the deals data*/
NSMutableArray *ResponseData = [items objectForKey:@"deals"];

/*Get the count and based on this loop through the objects.*/    
NSLog(@"deals data count is %d",[ResponseData count]);

Here i got exception while printing the count.

Following is the structure of my data.

    "meta": {
        "code": 200
    "response": {
        "deals": [
                "id": 32373, 
                "date_added": "2011-01-13 12:12:50", 
                "end_date": "2011-01-14 10:00:00", 
                "active": 1, 
                "discount": {
                    "raw": 71, 
                    "formatted": "71%"
                "price": {
                    "raw": "85.00", 
                    "formatted": "$85"
                "value": {
                    "raw": "300.00", 
                    "formatted": "$300"
                "title": "$85 For $300 Babyface Facial At Park Avenue MedSpa", 
                "yahoo_title": "71% off Babyface Facial", 
                "url": "http://yahoo.com/aff/click/?deal=AvwTADtE&key=F374EFbM", 
                "yahoo_url": "http://yahoo.com/new-york/livingsocial/85-for-300-babyface-facial-at-park-avenue-medspa/", 
                "mobile_url": "http://m.yahoo.com/new-york/livingsocial/85-for-300-babyface-facial-at-park-avenue-medspa/",
                "images": {
                    "image_big": "http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/85-for-300-babyface-facial-at-park-avenue-medspa-1294920769_display_image.jpg", 
                    "image_small": "http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/85-for-300-babyface-facial-at-park-avenue-medspa-1294920769_small_image.jpg"
                "division": {
                    "slug": "new-york", 
                    "name": "New York", 
                    "active": 1, 
                    "time_zone_diff": -4, 
                    "lat": "40.7142690000000000", 
                    "lon": "-74.0059730000000000", 
                    "url": "http://yahoo.com/new-york/"
                "tags": [
                        "name": "Facial", 
                        "slug": "facial", 
                        "url": "http://yahoo.com/new-york/deals/facial/"
                        "name": "Spa", 
                        "slug": "spa", 
                        "url": "http://yahoo.com/new-york/deals/spa/"
                "business": {
                    "name": "Park Avenue MedSpa", 
                    "url": "", 
                    "locations": [
                            "address": "565 Park Ave", 
                           "locality": "New York",
                            "phone": "212-593-8821", 
                            "lat": null, 
                            "lon": null,
                            "state": NY,
                            "zip_code": "11211"
                "source": {
                    "name": "LivingSocial", 
                    "slug": "livingsocial", 
                    "paid": 0, 
                    "url": "http://yahoo.com/new-york/livingsocial"

Source: (StackOverflow)

Using AFNetworking or JSONKit to talk to a Node.js express webserver

If all I wanted to do with a webserver was to request data and send commands from an iPhone app, all I'd need for that is AFJSONRequestOperation, correct? Why are some people also using JSONKit with AFNetworking? If I use JSONKit then do I still need to use AFNetworking?

Source: (StackOverflow)

Add objects to dictionary created by JSONKit?

In my project I have to load a number of json files. I parse them with JSONKit and after every single parsing with

NSMutableDictionary *json = [myJSON objectFromJSONString]; 

I add them to an array like:

[self.themeArray addObject:json];

This works fine so far. Now I need to pass the dictionaries arround between views. Works so far as well, but I need to add few more objects to the dictionary object-> json. Even it I declared json as NSMutableDictionary it does not allow me to add objects as it seems the JSONKit parser creates non-mutable dictionaries.

I was thinking about creating an object which contains the json dictionary and my additional data side by side so I wouldn´t have to change the json dictionary. I could even change it to NSDictionary because there is no need to change it. But that seems somehow not-elegant to me.

Do you have any idea how I can solve this issue without changing the JSONKit lib?

Thanks in advance!


i just tried after changing my code to

NSMutableDictionary *json = [[myJSON objectFromJSONString] mutableCopy];

something like this

[[self.theme objectForKey:@"theme"]  setObject:sender forKey:@"sender"];
[[self.theme objectForKey:@"theme"]  setValue:sender forKey:@"sender"];

Xcode throws an exception:

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '* -[JKDictionary setObject:forKey:]: mutating method sent to immutable object'

I assume that´s due to the fact there are still nested dictionaries in the superior dictionary. Then i would have to interate through my json object to copy all dictionaries to mutable dictionaries, right?

Perhaps it's better to switch to NSJSONSerialization as suggested by Guillaume.


I just tried something like this

[self.theme  setValue:sender forKey:@"sender"];

And it works now! It was as i assumend. Only the json object was copied to a mutable object. Probably obvious to you, it was not to me.

Thank you all for your help!


Finally i changed my code again after i could not manage to change all objects deep inside my dictionary data to mutable objects. I threw out JSONKit and use now NSJSONDeserialization as recommendet here with the option NSJSONReadingMutableContainers. My code looks now like this and all containers (arrays and dictionaries) are mutable deep inside too. That makes me happy! ;-)

NSMutableDictionary *json = [NSJSONSerialization JSONObjectWithData:myJSON options:NSJSONReadingMutableContainers error:&jsonParsingError];

Source: (StackOverflow)

JSONKit for iphone app?

Will apple choose to not allow an app to go to the app store if we use JSONKit to parse JSON's from our php document? I would like to use JSONSerializable but that is for ios5 and I am not going to alienate ios4 members on 3gs by doing that.

Source: (StackOverflow)

Performance of object_setClass() instead of assigning isa pointer

I noticed with with the latest update to XCode (4.6), I was given a warning about a couple of lines in JSONKit.m. Specifically, lines that set the class of an object:

dictionary->isa = _JKDictionaryClass;

These are marked as deprecated with a note that the preferred method was to use object_setClass():

object_setClass(dictionary, _JKDictionaryClass);

When I asked why it was preferred to simply silence the warning, the response was:

Everything works fine even if new Xcode version complains, I don't want to :
1) test each project where i use JSONKit to check if everything goes fine after object_setClass()
2) loose cpu cycles, which is the reason why i use JSONKit over NSJSONSerialization for example. My current application parses json files that weights 600K-1M

Just how much of a performance hit are we talking about here?


I am more interested in

dictionary->isa = _JKDictionaryClass vs object_setClass()

than JSONKit vs NSJSONSerialization.

Source: (StackOverflow)

How do you get mutable dictionaries from AFNetworking and AFJSONRequestOperation?

I'm using JSONKit with AFNetworking's AFHTTPClient (with AFJSONRequestOperation) and I can't seem to figure out how one might trigger the use of the mutableObjectFrom... methods of JSONKit rather than the normal parser methods which return (or arrays of) JKDictionary.

Is this possible without modifying AFNetworking?

Source: (StackOverflow)