Install json-framework
If you are attempting to write a Iphone application to talk to a webservice, JSON is one of the best ways to go. Now unfortunately there is no native support in the Iphone SDK for JSON. There is a project called json-framework that provides a framework called json-framework.
There is little documentation on how to install it though. Recently I found a news group posting on how to do it along with a dmg! I have mirrored the dmg file just in case it gets removed from that posting.
So here are some instructions on how to install it.
- Download the dmg file
- Make a directory called SDKs in your ~/Library/ directory. So if you username is bob. it would be /Users/bob/Library/SDKs
- Copy the JSON directory to SDKs so you should have a directory called /Users/bob/Library/SDKs/JSON which has iphoneos.sdk and iphonesimulator.sdk directories inside it.
- In Xcode load up your project and go to Project -> Edit Project Settings. You will see a box like this
- At the top you will see Additional SDKs. Double click that and you will see
- Now click the + sign and it will prompt you to add a directory. You will enter the following line
$HOME/Library/SDKs/JSON/$(PLATFORM_NAME).sdk
- Now you need to add in the linker options. So now look for Other Linker Flags and add in the following
-ObjC -ljson
- Now you can import the <JSON/JSON.h> header file and begin coding.
I have also mirrored their test application they built in the news group post. So if you download that and make the project changes there, you should be able to compile touchJSON into your application.


Hi, I’m the author of both the JSON Framework and the newsgroup posting you reference above.
I just wanted to let you know that from version 2.1 onwards, official downloads of the framework come with iPhone-ready SDKs.
(BTW: I’m a bit curious why the the slug refers to touchjson; that’s part of an unrelated project called touchcode.)
Hello,
I can’t make the JSON sdk run with SDK 2.1. I keep getting the following error: JSON/JSON.h: No such file or directory. When I open your project, it works. I checked extensively the “Additional SDKs” and the “Other Linker Flags” and they are exactly the same as your project. Please HELP HELP HELP.
David
I just started using google toolkit for mac, including unit testing framework. When I build using the unit test target (set up according to their tut), the Json framework is not linking and the selectors are unrecognized.
Any idea what I need to do so that json framework loads into testing context?
Got this resolved! I had failed to add “Other Linker Flags” to the “Unit Test” target. You have to set up the Unit Test target separately from your main app target and associate the same links. Works like a CHARM!
Hello, I have added the JSON.framework to ~/Library/Frameworks, added the parts to “Additional SDKs” and “Other Linked Flags” mentioned here, and still can’t compile code that includes the JSON framework. I completed the instructions here in comments as well, trying to create another target, as well as the instructions in the INSTALL of the DMG download. I am on Xcode 2.2.2 and running latest Leopard. Any more help please?
Whoops make that Xcode 3.1.1
I also had problems getting this to work in XCode 3.1.1, until I changed
$HOME/Library/SDKs/JSON/$(PLATFORM_NAME).sdk
to
$HOME/Library/SDKs/JSON/$(PLATFORM_NAME).sdk/
Also, I copied the JSON folder into place from the command line, since Finder was tricking me with the file locations somehow.
Hope it helps.
Hmm… However, I did *not* have to make that change in order to compile the testjson project in the next post. Does anyone have a clue why this should be?
Test example worked like a charm! Excellent package…going to try it using the Google AJAX Search API (non-js)…and see what data it returns.
Thanks every much.
You’ve helped me alot.
Just add -ObjC in Other Linker Flags in project settings, else you will have compile error.
Brilliant – thanks so so much!
i followed all the steps explained above and then developed a demo project based upon it…and there is only one error..that i couldnt resolve….
the error is:
ld: library not found for -lgcc_s.10.5
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
please help me..thnx in advance