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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:47:09+00:00 2026-05-27T23:47:09+00:00

If you had a NSString containing JSON data and you needed to retrieve the

  • 0

If you had a NSString containing JSON data and you needed to retrieve the VALUE for a given KEY, but you needed to read the RAW JSON string for that key, how would you do it?

Suppose that the VALUE has several dictionaries and arrays, and you needed the raw string just to calculate a signature.

Is there anything out there that could do this? JSONKit doesn’t provide this functionality. I’d like to avoid writing a custom parser just for this feature.

  • 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-27T23:47:10+00:00Added an answer on May 27, 2026 at 11:47 pm

    Actually JSONKit is very good for satisfying your needs.
    First you should convert your string to NSData to use JSONKit to parse it, then you can find the value of the key you want, finally JSONKit can convert it back to NSString.

    Some codes will show more details here, hope to help:

    NSString *jsonString = @"{\"k\":{\"age\":1,\"desc\":\"something cool\"}}";
    NSData *rawData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    
    id jsonObject = [rawData objectFromJSONData];
    NSLog(@"json object is:%@", jsonObject);
    
    id kObject = [jsonObject valueForKey:@"k"];
    NSLog(@"the object of key k is: %@", kObject);
    
    NSString *kString = [kObject JSONString];
    NSLog(@"raw string of k is: %@", kString);
    

    And the output will look like:

    2012-01-04 12:50:41.234 App[1966:207] json object is:{
        k =     {
            age = 1;
            desc = "something cool";
        };
    }
    2012-01-04 12:50:41.235 App[1966:207] the object of key k is: {
        age = 1;
        desc = "something cool";
    }
    2012-01-04 12:50:41.235 App[1966:207] raw string of k is: {"age":1,"desc":"something cool"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Had a good search here but can't see anything that gets my mind in
I have a problem that I had working in a test but now in
Had a page that was working fine. Only change I made was to add
I had a discussion with some colleagues mentioning that there are not too many
I had to delete all the rows from a log table that contained about
I had the idea of a search engine that would index web items like
My application gets handed an NSString containing an unsigned int . NSString doesn't have
Coming from a ruby background, I'm wishing NSString had some convenient methods like the
NSString *myText = @mary had a little lamb; NSString *regexString = @mary(.*?)little; for(NSString *match
Say you had the following two constructors: - (id)initWithTitle:(NSString *)title; - (id)initWithTitle:(NSString *)title page:(NSString

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.