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

  • Home
  • SEARCH
  • 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 6569227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:36:00+00:00 2026-05-25T14:36:00+00:00

framework. Hi I’m using json-framework. How to get sorted string when using JSONRepresentation method?

  • 0

framework.
Hi I’m using json-framework.

How to get sorted string when using JSONRepresentation method?
Here is my code:

NSMutableDictionary *tUserIDParam = [NSMutableDictionary dictionary];

[tUserIDParam setObject:@"UserID" forKey:@"@key"];
[tUserIDParam setObject:@"string" forKey:@"@type"];
[tUserIDParam setObject:@"mark" forKey:@"#text"];

NSMutableDictionary *tPasswordParam = [NSMutableDictionary dictionary];
[tPasswordParam setObject:@"Password" forKey:@"@key"];
[tPasswordParam setObject:@"string" forKey:@"@type"];
[tPasswordParam setObject:@"123456" forKey:@"#text"];

NSArray *tParams = [NSArray arrayWithObjects:tUserIDParam,tPasswordParam, nil];
NSDictionary *tParam = [NSDictionary dictionaryWithObject:tParams forKey:@"param"];

NSMutableDictionary *tRequests = [NSMutableDictionary dictionary];
[tRequests setObject:[NSNull null] forKey:@"key"];
[tRequests setObject:[NSNull null] forKey:@"basic"];
[tRequests setObject:tParam forKey:@"conditions"];

NSDictionary *tRequest = [NSDictionary dictionaryWithObject:tRequests forKey:@"request"];

NSString *tJSONStrFromDict = [tRequest JSONRepresentation];

I want to get JSON string like:

{“request”:{“key”:null,”basic”:null,”conditions”:{“param”:[{“@key”:”UserID”,”@type”:”string”,”#text”:”mark”},{“@key”:”Password”,”@type”:”string”,”#text”:”123456″}]}}}

But I got this string from above code:

{“request”:{“basic”:null,”conditions”:
{“param”:[{“#text”:”mark”,”@key”:”UserID”,”@type”:”string”},{“#text”:”123456″,”@key”:”Password”,”@type”:”string”}]},”key”:null}}

I try to use SBJSONWriter sortKeys property,it does not work…

Have any way to solve my problem?

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-05-25T14:36:01+00:00Added an answer on May 25, 2026 at 2:36 pm

    NSMutableDictionary instance do not preserve the order of elements, neither in alphabeticallz order nor in the order they were inserted. This is independent of JSON.

    Furthermore, JSON’s data model for object doesn’t guarantee order either. If you want a certain order, you’ll have to use JSON arrays for the ordered parts.

    BTW.: The effect of SBJSONWriter sortKeys is to output the object elements (or properties) alphabetically sorted by the key name. This is what you get.

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

Sidebar

Related Questions

In the Full .NET framework you can use the Color.FromArgb() method to create a
After downloading all .NET framework symbols and sources using NetMassDownloader , is it possible
I am using Entity Framework. One of my Entities (MyEntity) has a dependency on
Been going through some framework classes using reflector and noticed a number of the
.NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development).
Entity framework provides great flexibility to update data in the same datacontext Dim personA
.NET Framework 3.5 comes with all the LINQ goodies, and also includes predefined generic
AVFoundation.framework is not where the documentation says it should be. I have iPhone SDK
The Compact Framework doesn't support Assembly.GetEntryAssembly to determine the launching .exe. So is there
What's the best framework for creating mock objects in Java? Why? What are the

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.