Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

Json response

jjanesjjanes Posts: 12Registered Users
edited March 2012 in iPhone SDK Development
Hi I have the following as a JSON response and I am trying to parse it out


{\"content\":
{\"issues\":
[
{\"id\":\"fe9b922a-455d99365f79f\",
\"title\":\"The Teachings of Meister Eckhart\",
\"display_url\":\"MARCH2012\",
\"preview_path\":\"http:play/gvxhguzBBwA\",
\"published_on\":\"03/01/2012 12:00:00\",
\"videos\":
[
{\"id\":\"ae462311-de3-ff84903df150\",
\"path\":\"/flv/0312inal/MARCH_0.mp4\",
\"title\":\"Live Meditation\",
\"description\":null,
\"hd_path\":null,
\"wide_thumbnail\":null,
\"thumbnail\":null,
\"speaker\":null,
\"duration\":null},
{\"id\":\"20227ac1-4af3179bc177bc1\",
\"path\":\"/flv/03181talk_01_01.flv\",
\"title\":\"The Teachings of Meister Eckhart\",
\"description\":null,
\"hd_path\":null,
\"wide_thumbnail\":null,
\"thumbnail\":null,
\"speaker\":null,
\"duration\":null},
{ \"id\":\"aa85a2a9-5f078279be849\",
\"path\":\"/flv/0312iv/08qa01.flv\",
\"title\":\"Any advice on how to deal terminal illness?\",
\"description\":null,
\"hd_path\":null,
\"wide_thumbnail\":null,
\"thumbnail\":null,
\"speaker\":null,
\"duration\":null},
{ \"id\":\"76c3b7a3-0bb26faadb017\",
\"path\":\"/flv/03v/011a02.flv\",
\"title\":\"Caring for ,I deal with the anger I feel?\",
\"description\":null,
\"hd_path\":null,
\"wide_thumbnail\":null,
\"thumbnail\":null,
\"speaker\":null,
\"duration\":null},
}
]
},
{\"issues\":
[
{\"id\":\"fe9b922a-4565f79f\",
\"title\":\"The Teachings of Meister Eckhart\",
\"display_url\":\"MARCH2002\",
\"preview_path\":\"http:play/gguzBBwA\",
\"published_on\":\"03/01/2012 12:00:00\",
\"videos\":
[
{\"id\":\"ae462311-de3-ff84f150\",
\"path\":\"/flv/0312inRCH_0.mp4\",
\"title\":\"Live Meditation\",
\"description\":null,
\"hd_path\":null,
\"wide_thumbnail\":null,
\"thumbnail\":null,
\"speaker\":null,
\"duration\":null},
.
.
.


This is only a partial listing of the actual code but it gives enough information to allow me to ask my question

I am a bit new to objective C and iOS5 so I am hoping for some basic help
So this JSON response has multiple issues elements and multiple videos elements in these issues elements .

So the way I understand it I can not use NSDictionary because of the duplicate issues and videos elements
I was wondering how if I can parse this with NSSet then enumerate them but how would I reference these elements so that all the videos associated with a given issues element.

So would something like this work

NSArray issues\":
NSDictionary \"id\":\"fe9b922a-455d99365f79f\",
NSDictionary \"title\":\"The Teachings of Meister Eckhart\",
NSDictionary \"display_url\":\"MARCH2012\",
NSDictionary \"preview_path\":\"http:play/gvxhguzBBwA\",
NSDictionary \"published_on\":\"03/01/2012 12:00:00\",
NSArray\"videos\":

NSDictionary \"id\":\"ae462311-de3-ff84903df150\",
NSDictionary \"path\":\"/flv/0312inal/MARCH_0.mp4\",
NSDictionary \"title\":\"Live Meditation\",
NSDictionary \"description\":null,
NSDictionary \"hd_path\":null,
NSDictionary \"wide_thumbnail\":null,
NSDictionary \"thumbnail\":null,
NSDictionary \"speaker\":null,
NSDictionary \"duration\":null},

Assuming the above will work
Two things confuse me
How can I tell if the example Json result above is able to be parsed into these objects.
Second, how do I access these elements once parsed

Can some wonderful person enlighten me a bit
Post edited by jjanes on

Replies

  • chiataytudaychiataytuday Posts: 40Registered Users
    edited March 2012
    jjanes;420999 said:
    Hi I have the following as a JSON response and I am trying to parse it out


    {\"content\":
    {\"issues\":
    [
    {\"id\":\"fe9b922a-455d99365f79f\",
    \"title\":\"The Teachings of Meister Eckhart\",
    \"display_url\":\"MARCH2012\",
    \"preview_path\":\"http:play/gvxhguzBBwA\",
    \"published_on\":\"03/01/2012 12:00:00\",
    \"videos\":
    [
    {\"id\":\"ae462311-de3-ff84903df150\",
    \"path\":\"/flv/0312inal/MARCH_0.mp4\",
    \"title\":\"Live Meditation\",
    \"description\":null,
    \"hd_path\":null,
    \"wide_thumbnail\":null,
    \"thumbnail\":null,
    \"speaker\":null,
    \"duration\":null},
    {\"id\":\"20227ac1-4af3179bc177bc1\",
    \"path\":\"/flv/03181talk_01_01.flv\",
    \"title\":\"The Teachings of Meister Eckhart\",
    \"description\":null,
    \"hd_path\":null,
    \"wide_thumbnail\":null,
    \"thumbnail\":null,
    \"speaker\":null,
    \"duration\":null},
    { \"id\":\"aa85a2a9-5f078279be849\",
    \"path\":\"/flv/0312iv/08qa01.flv\",
    \"title\":\"Any advice on how to deal terminal illness?\",
    \"description\":null,
    \"hd_path\":null,
    \"wide_thumbnail\":null,
    \"thumbnail\":null,
    \"speaker\":null,
    \"duration\":null},
    { \"id\":\"76c3b7a3-0bb26faadb017\",
    \"path\":\"/flv/03v/011a02.flv\",
    \"title\":\"Caring for ,I deal with the anger I feel?\",
    \"description\":null,
    \"hd_path\":null,
    \"wide_thumbnail\":null,
    \"thumbnail\":null,
    \"speaker\":null,
    \"duration\":null},
    }
    ]
    },
    {\"issues\":
    [
    {\"id\":\"fe9b922a-4565f79f\",
    \"title\":\"The Teachings of Meister Eckhart\",
    \"display_url\":\"MARCH2002\",
    \"preview_path\":\"http:play/gguzBBwA\",
    \"published_on\":\"03/01/2012 12:00:00\",
    \"videos\":
    [
    {\"id\":\"ae462311-de3-ff84f150\",
    \"path\":\"/flv/0312inRCH_0.mp4\",
    \"title\":\"Live Meditation\",
    \"description\":null,
    \"hd_path\":null,
    \"wide_thumbnail\":null,
    \"thumbnail\":null,
    \"speaker\":null,
    \"duration\":null},
    .
    .
    .


    This is only a partial listing of the actual code but it gives enough information to allow me to ask my question

    I am a bit new to objective C and iOS5 so I am hoping for some basic help
    So this JSON response has multiple issues elements and multiple videos elements in these issues elements .

    So the way I understand it I can not use NSDictionary because of the duplicate issues and videos elements
    I was wondering how if I can parse this with NSSet then enumerate them but how would I reference these elements so that all the videos associated with a given issues element.

    So would something like this work

    NSArray issues\":
    NSDictionary \"id\":\"fe9b922a-455d99365f79f\",
    NSDictionary \"title\":\"The Teachings of Meister Eckhart\",
    NSDictionary \"display_url\":\"MARCH2012\",
    NSDictionary \"preview_path\":\"http:play/gvxhguzBBwA\",
    NSDictionary \"published_on\":\"03/01/2012 12:00:00\",
    NSArray\"videos\":

    NSDictionary \"id\":\"ae462311-de3-ff84903df150\",
    NSDictionary \"path\":\"/flv/0312inal/MARCH_0.mp4\",
    NSDictionary \"title\":\"Live Meditation\",
    NSDictionary \"description\":null,
    NSDictionary \"hd_path\":null,
    NSDictionary \"wide_thumbnail\":null,
    NSDictionary \"thumbnail\":null,
    NSDictionary \"speaker\":null,
    NSDictionary \"duration\":null},

    Assuming the above will work
    Two things confuse me
    How can I tell if the example Json result above is able to be parsed into these objects.
    Second, how do I access these elements once parsed

    Can some wonderful person enlighten me a bit
    Show NSLog, you will see and know do it
Sign In or Register to comment.