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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:59:55+00:00 2026-05-24T13:59:55+00:00

I have a very large response from server of JSON string. I converted it

  • 0

I have a very large response from server of JSON string. I converted it to JSON object and then get the keys and iterate it.

The problem is that when I iterate it isnt in the same order as in response from server.

Next then I apply another method by adding all the keys in List<String> and the sort it and then get the iterator of that but still it isn’t as I required (as in response).

Code example is here:

JSONObject jsonObject = new JSONObject(responseString);
    Iterator<String> myIter = jsonObject.keys();


    List<String> sortKey = new ArrayList<String>();

    while(myIter.hasNext()){
        sortKey.add(myIter.next());
    }
    Collections.sort(sortKey);
  • 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-24T13:59:57+00:00Added an answer on May 24, 2026 at 1:59 pm

    The order of the keys of a JSON object is not supposed to be meaningful. If you want a specific order, you should use an array, not an object.

    Your Java code sorts the keys alphabetically. There is no way to get the initial ordering of the keys in the object.

    Reference 1:

    The order of the keys is undefined

    Reference 2:

    An object is an unordered set of name/value pairs

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

Sidebar

Related Questions

I have a very large array I need to check for debugging purposes, problem
I have a very large table in Mathematica ((dimcub-1)^3 elements) coming from an inverse
I have a very large code base that contains extensive unit tests (using CppUnit).
We have some very large data files (5 gig to 1TB) where we need
I have a very large (~6GB) SVN repository, for which I've written a batch
I have a very large file that looks like this (see below). I have
I have a very large codebase (read: thousands of modules) that has code shared
I have a very large C project with many separate C files and headers
I have a very large app, 1.5 million lines of C++, which is currently
Here at work we have a very large application with multiple sub applications. (500

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.