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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:58:34+00:00 2026-05-18T20:58:34+00:00

I have to deserialize a JSON object like this [{Key:{id:0, Name:an Object}, Value:true}, {Key:{id:0,

  • 0

I have to deserialize a JSON object like this

[{"Key":{"id":0, "Name":"an Object"}, "Value":true},
{"Key":{"id":0, "Name":"an Object"}, "Value":true}]

I know how to deserialize arrays and singleobjects or variables. but I’m in the blue about dictionaries.

I’m using the following to read an array

NetworkEvent n = (NetworkEvent) evt;
byte[] data = (byte[]) n.getMetaData();

AnObject[] anObject= null;
 try {
     JSONArray json = new JSONArray(new String(data, "UTF-8"));
     anObject= AnObject.getAnObjects(json);
 } catch (Exception ex) {
     ex.printStackTrace();
 }    

The final code solution:

        Object[] objects= new Object[json.length()];
        for (int i = 0; i < json.length(); ++i) {

            Key key= null;
            Value value = null;
            try {
                JSONObject keyValuePair = json.getJSONObject(i);
                key= Key.getKey(keyValuePair.getJSONObject("Key"));
                value= keyValuePair.getBoolean("Value");
            } catch (JSONException ex) {
                ex.printStackTrace();
            }

          Object object= new object();
          object.setKey(key);
          object.setValue(value);

          Objects[i] = object;
        }
        return objects;
  • 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-18T20:58:35+00:00Added an answer on May 18, 2026 at 8:58 pm

    What you have there is not a JSON object. It is an array of JSON objects, and therefore your current code should work.

    I think that your “problem” is that you are using the wrong terminology.

    This is an attribute or name/value pair:

    "id":0
    

    This is an object:

    {"id":0, "Name":"an Object"}
    

    This is also an object:

    {"Key":{"id":0, "Name":"an Object"}, "Value":true}
    

    This is an array (of objects)

    [{"Key":{"id":0, "Name":"an Object"}, "Value":true},
     {"Key":{"id":0, "Name":"an Object"}, "Value":true}]
    

    For more details, refer to the json.org site.

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

Sidebar

Related Questions

Suppose I have a json object that looks like: { id: 1, name: john
I have some JSON data that looks like this: { data: [{ name:John Smith,
I have a JSON structure like this: { id:100 contactInfo: { name: John Doe
I basically have something like this: void Foo(Type ty) { var result = serializer.Deserialize<ty>(inputContent);
I have a Json file that looks like this: [ { field:val }, ....
I have a JSON string and I'd like to use to compose an object.
I have some JSON that I need to deserialize so I'm using JavaScriptSerializer.DeserializeObject like:
we have a json serializer and deserializer downloaded, it reads the profile object find,
I am trying to serialize/deserialize JSON in Android using GSON. I have two classes
I have the following xml I'd like to deserialize into a class <?xml version=1.0

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.