Re: Deserializing JSON

11 views
Skip to first unread message

Jesse Tayler

unread,
Aug 24, 2012, 8:25:29 PM8/24/12
to iphonesdkd...@googlegroups.com

did you validate that json?

what's the error message?


On Aug 24, 2012, at 7:32 PM, don <donj...@gmail.com> wrote:

> Here is a JSON object but I can't extract it.
> This JSON has 4 array items but it's variable.
> And each item has 3 keys, keyword, status, username.
> Can anybody give me advice?
> -------------------
>
> {
> agent = {
> 0000001001 = {
> keyword = "test 0424 ";
> status = 0;
> userName = "User #1001";
> };
> 0000001002 = {
> keyword = "test 0424 ";
> status = 0;
> userName = "User #1002";
> };
> 0000001003 = {
> keyword = "test 0424 ";
> status = 0;
> userName = "User #1003";
> };
> 0000001004 = {
> keyword = "test 0424 ";
> status = 0;
> userName = "User #1004";
> };
> };
> }
>
>
> --
> You received this message because you are subscribed to the Google Groups "iPhone SDK Development" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/iphonesdkdevelopment/-/k09UIpiaBPYJ.
> To post to this group, send email to iphonesdkd...@googlegroups.com.
> To unsubscribe from this group, send email to iphonesdkdevelop...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/iphonesdkdevelopment?hl=en.

jrparro

unread,
Aug 24, 2012, 9:30:40 PM8/24/12
to iphonesdkd...@googlegroups.com, iphonesdkd...@googlegroups.com
Try to check first if it's a correct JSON format-

If you're using iOS 5+, there's already a built-in NSJSONSerialization class that can do parse/serialize json objects. Try to look for it.


Sent from my iPad

On 25 Aug, 2012, at 8:59 AM, don <donj...@gmail.com> wrote:


I received that JSON object from server.
I should extract userID(0000001001,0000001002, 0000001003...), status, keyword, status, userName to display in the TableView.
I'm not sure this is correct JSON format.
If not, please tell me and I will request our server programmer.
 
> To unsubscribe from this group, send email to iphonesdkdevelopment+unsub...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/iphonesdkdevelopment?hl=en.

--
You received this message because you are subscribed to the Google Groups "iPhone SDK Development" group.

By Nourishing Knowledge

unread,
Aug 24, 2012, 9:37:44 PM8/24/12
to iphonesdkd...@googlegroups.com
You will also need to make sure if it is a dictionary of arrays or just an array

Sent from my iPhone

On Aug 24, 2012, at 5:59 PM, don <donj...@gmail.com> wrote:


I received that JSON object from server.
I should extract userID(0000001001,0000001002, 0000001003...), status, keyword, status, userName to display in the TableView.
I'm not sure this is correct JSON format.
If not, please tell me and I will request our server programmer.
 

On Friday, August 24, 2012 5:25:29 PM UTC-7, jtayler wrote:
> To unsubscribe from this group, send email to iphonesdkdevelopment+unsub...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/iphonesdkdevelopment?hl=en.

--
You received this message because you are subscribed to the Google Groups "iPhone SDK Development" group.

Tomo Kawata

unread,
Aug 25, 2012, 12:37:26 PM8/25/12
to iphonesdkd...@googlegroups.com
check out what is json, and json format.

it looks not a correct json format.

On Aug 26, 2012, at 1:19 AM, don wrote:

I validated it and here is the result.

Parse error on line 1: { agent={ 0000 -----^ Expecting 'STRING', '}'
How to make it correct JSON format? I will request server side to give me correct JSON format.
Can you make it correct format?
(0000001001, 0000001002...are userID) 

To post to this group, send email to iphonesdkd...@googlegroups.com.
To unsubscribe from this group, send email to iphonesdkdevelop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/iphonesdkdevelopment?hl=en.

------------------------------------
| Tomo Kawata
| 090 8126 1542
tkawa...@gmail.com
------------------------------------

Jonathan Querubina

unread,
Aug 25, 2012, 6:16:12 PM8/25/12
to iphonesdkd...@googlegroups.com
Why dont you change from json to plist?

Sent from my iPad

On Aug 25, 2012, at 1:35 PM, don <donj...@gmail.com> wrote:

It seems hte JSON data I posted is not correct.
How to make it correct JSON format? I will request server side to give me correct JSON format.

Can you make it correct format? I will request server side programmer to send me correct format of JSON data.

Here is additional information.


"agent" is fixed dictionary key 

0000001001, 0000001002...are userID and user's count is variable.

And each array item's dictionary keys(keyword, status, userName) are fixed.


Thanks in advance!

By Nourishing Knowledge

unread,
Aug 25, 2012, 1:14:52 PM8/25/12
to iphonesdkd...@googlegroups.com
Are you pulling in php?

Sent from my iPhone

On Aug 25, 2012, at 9:35 AM, don <donj...@gmail.com> wrote:

It seems hte JSON data I posted is not correct.
How to make it correct JSON format? I will request server side to give me correct JSON format.

Can you make it correct format? I will request server side programmer to send me correct format of JSON data.

Here is additional information.


"agent" is fixed dictionary key 

0000001001, 0000001002...are userID and user's count is variable.

And each array item's dictionary keys(keyword, status, userName) are fixed.


Thanks in advance!





On Friday, August 24, 2012 6:37:44 PM UTC-7, BNKtech wrote:

Alok Srivastava

unread,
Aug 27, 2012, 1:07:51 AM8/27/12
to iphonesdkd...@googlegroups.com
Hi All,
What i have done to parse such a kind of JSON. Firstly attach the JSON framework.
then
Nsdictoonary *jsonObj=[jsonVariable jsonvalue];
jsonVariable is the Variable in which you hold the json object whci is come from your server.
nsdictionary *inerObject=[jsonObj valueforkey:@"agent"];
nsarray *allkeys=[inerObject allKeys];
for(key in allKeys){
      nsstring *keyobject=[allkeys valueforkey:@"key"];
nsstring *status=[keyobject valueforkey:@"status"];

}

same you can get the other values. 
Reply all
Reply to author
Forward
0 new messages