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 9119143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:19:28+00:00 2026-06-17T05:19:28+00:00

Here is the simplified JSON file, I need to download it from a net

  • 0

Here is the simplified JSON file, I need to download it from a net service and parse results in a table!

EDIT: I provide now more precise code, cleaned and formatted by online tool:

{
  "main": [
    {
      "id": 0, <--- float value
      "type": "type0", <--- STRING value
      "valueA": {
        "valueA1": 1, <--- float value
        "valueA2": 2, <--- float value
        "valueA3": 3  <--- float value
      },
      "valueB": {
        "valueB1": 1, <--- float value
        "valueB2": 2  <--- float value
      },
      "valueC": [
        {
          "valueC1": "string0C1", <--- STRING value
          "valueC2": 2, <--- float value
          "valueC3": 3, <--- float value
        }
      ]
    },

FORMATTED by online tool jsonviewer.stack.hu:

enter image description here

I need to parse it with AFJSONRequestOperation, and I write this code:

NSMutableArray *main = [JSON objectForKey:@"main"];
arrayID = [main valueForKey:@"id"];
arrayType = [main valueForKey:@"type"];

NSMutableArray *arrayValueC = [main valueForKey:@"valueC"];
NSMutableString *stringC1 = [arrayValueC valueForKey:@"valueC1"]; 

// I CANT USE objectForKey, XCode give an exception -[__NSArrayI objectForKey:]: unrecognized selector sent to instance

NSLog(@"id: %@",arrayID);
NSLog(@"type: %@",arrayType);
NSLog(@"string: %@",stringC1);

When I parse, I get this results from NSLog:

id: (
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9
)

type: (
    type0,
    type1,
    type2,
    type3,
    type4,
    type5,
    type6,
    type7,
    type8,
    type9
)

string: (
        (
        "string0C1"
    ),
        (
        "string2C1"
    ),
        (
        "string2C1"
    ),
        (
        "string3C1"
    ),
        (
        "string4C1"
    ),
        (
        "string5C1"
    ),
        (
        "string6C1"
    ),
        (
        "string7C1"
    ),
        (
        "string8C1"
    ),
        (
        "string9C1"
    )
)

As u can see its all perfect, I can extrapolate every value of ID (float) and TYPE (string), but I hate the round brackets in every object of the valueC1 string: how can I get the clean valueC1 without brackets and quotation marks? Please if u can provide some code. Thanks!

  • 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-06-17T05:19:30+00:00Added an answer on June 17, 2026 at 5:19 am

    Don’t use valueForKey:. Use objectForKey: instead. This is probably the major problem. But once you use it, you might run into new problem:

    The following contains a problem that will manifest itself when arrayValueA is accessed the first time:

    NSMutableArray *arrayValueA = [arrayMain objectForKey:@"valueA"];
    

    The element stored at valueA is an object i.e. a dictionary and not an array.

    Finally, your simplified JSON is invalid anyway. Several values are missing double quotes, e.g.:

    "id": id0
    

    should be:

    "id": "id0"
    

    You better shows the real JSON data and the real code.

    Update:

    You should be able to access the JSON data with the following code:

    NSArray *main = [JSON objectForKey:@"main"];
    NSDictionary* main0 = [main objectAtIndex:0];
    arrayID = [main0 objectForKey:@"id"];
    arrayType = [main0 objectForKey:@"type"];
    
    NSArray *arrayValueC = [main objectForKey:@"valueC"];
    NSDictionary *elem0 = [arrayValueC objectAtIndex:0];
    NSString *stringC1 = [arrayValueC objectForKey:@"valueC1"]; 
    
    NSLog(@"id: %@",arrayID);
    NSLog(@"type: %@",arrayType);
    NSLog(@"string: %@",stringC1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Json.NET in my WCF data service. Here's my class (simplified): [DataContract] public
Here is the simplified table structure of PRICES : SKU PriceType FromDate ToDate Price
Here is a simplified version of the code I use. I need to rewrite
Here's simplified .htaccess file: RewriteEngine On RewriteRule ^index$ index.php On my local lamp server
I have a complicated json structure. Here it is simplified because it happens with
I cannot access joined table with PHPActiveRecord/Twig. Here is simplified code. It has two
The JSON source formatted with jsonviewer.stack.hu: My Parse Method (simplified): - (void)parseMethod { //
Here is simplified version of my requirement I have a java class say Processor
I've got 3 tables that are something like this (simplified here ofc): users user_id
I look at example of dropdown menu here . Here is simplified jsfiddle example.

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.