Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7683087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:42:58+00:00 2026-05-31T18:42:58+00:00

I am trying to parse a rather large json file, and I am beginning

  • 0

I am trying to parse a rather large json file, and I am beginning to have a bit of an issue

An example of what the JSON looks like is this

{
"info":"info",
"products":[
            {
            "name":"HomeScreen",
            "screens":[
                       {
                       "name":"View Details",
                       "id":1,
                       "title":{
                       "name":"Default_Name",
                       "number":"Default_Number"
                       },
                       "widgets":[
                                  {
                                  "id":8,
                                  "splits":[
                                            {
                                            "control":{
                                            "type":1,
                                            "limitLow":0,
                                            "limitHigh":100
                                            },
                                            "texts":[
                                                     {
                                                     "value":"blah",
                                                     "style":{
                                                     "size":10,
                                                     "colour":"#FFFFFF"
                                                     },
                                                     "test1":"asd",
                                                     "test2":"zxc"
                                                     }
                                                     ]
                                            }
                                            ]
                                  },

And so on

I want to be able to parse the texts values and place them in an object. I have the class created, but I am unable to retrieve the exact values. I have tried doing the following

   NSArray *test = [MainJSON valueForKeyPath:@"products.screens.widgets.splits.texts"];

for(NSDictionary *dict in test){

    NSLog(@"%@", [dict valueForKeyPath:@"value"]);
}

It prints out the values but with loads of brackets as well, and I need to be able to get the exact value from the JSON. I also tried doing

 for(int i = 0; i < [test count]; i++){

    for(NSDictionary *dict in [test objectAtIndex:i]){

        NSLog(@"%@", [dict valueForKeyPath:@"value"]);
    }

}

But same problem. Could anyone tell me what I am doing wrong. I have tried soo many different solutions, but nothing seems to be working.

Thanks in advance

EDIT Output for example I gave is

2012-03-21 12:12:18.731 JSONObjects[4467:f803] (
    (
            (
                    (
            "CURRENT BALANCE",
            "[var:UnbilledAmount]"
        )
    ),
            (
                    (
            "THE BILL IS DUE IN",
            "[var:DaysToBill] DAYS"
        )
    ),
            (
                    (
            TEXTS,
            "[var:UsedTexts] of [var:MaxTexts]"
        ),
                    (
            DATA,
            "[var:UsedData] of [var:MaxData]"
        ),
                    (
            TEXTS,
            "[var:UsedMinutes] of [var:MaxMinutes]"
        )
    )
)
)
2012-03-21 12:12:18.732 JSONObjects[4467:f803] (
        (
    ),
        (
    ),
        (
    ),
        (
    ),
        (
    )
)
2012-03-21 12:12:18.732 JSONObjects[4467:f803] (
        (
    )
)
2012-03-21 12:12:18.733 JSONObjects[4467:f803] (
        (
    )
)
2012-03-21 12:12:18.733 JSONObjects[4467:f803] (
        (
    )
)
2012-03-21 12:12:18.734 JSONObjects[4467:f803] (
        (
    )
)
2012-03-21 12:12:18.734 JSONObjects[4467:f803] (
        (
    )
)

As you can see a lot of brackets which is deeply frustrating.

Edit2:

Test is an array of NSDictionary objects though, here is the code

   NSString *filePath = [[NSBundle mainBundle] pathForResource:@"json" ofType:@"json"];  
NSData *myData = [NSData dataWithContentsOfFile:filePath];  

NSString *responseString = [[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];

NSDictionary *MainJSON = [responseString JSONValue];
NSArray *test = [MainJSON valueForKeyPath:@"products.screens.widgets.splits.texts"];

Edit:

I have been able to get a single value using this code

 for(NSDictionary *dict in [textArray objectAtIndex:0]){

 NSLog(@"%@", [[[[dict valueForKey:@"value"]objectAtIndex:0]objectAtIndex:0]objectAtIndex:0]);
 }

However this is a bit messy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:42:59+00:00Added an answer on May 31, 2026 at 6:42 pm

    I figured it out in the end. In the products Object class, I didn’t add in an NSDictionary object into the class object. As I needed to make a dictionary of the screens. Then loop through that dictionary, find the widgets, then create a dictionary of that array, find the splits, then make a dictionary of that array, and then loop through that and so on until I got to texts. Now it works perfectly! 😀

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather complex Flat File that I'm trying to parse using SSIS.
I have a file log that I would like to parse and am having
I am trying to parse a rather long log file and creating a better
Trying to parse Maplines for an airport. Each airport can have X number of
Trying to parse some XML but apparently this is too much for a lazy
I'm trying to parse an INI file using C++. Any tips on what is
I have been trying to parse Java exceptions that appear in a log for
I'm trying to pass a rather large post request to php, and when I
I'm having troubles getting a regex to work. I'm trying to parse a large,
I'm trying to find a good way to parse JSON in C. I really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.