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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:28:39+00:00 2026-05-31T19:28:39+00:00

I have a JSON stream being generated by a server side C++ program that

  • 0

I have a JSON stream being generated by a server side C++ program that is currently in development. I’ve been given a sample of the resulting JSON and I am concerned that I will have to parse the json by hand, that I won’t be able to use normal class mapping provided by tools such as GSON or Jackson.

Please take a look at the following (somewhat) contrived example they have provided. The sections I’m concerned with are the meta data “serie” array having different parameters. The key – “key” for example is present in only one of the array elements. Will this not cause issues trying to map this array to a collection of a specific class?

Lastly, I am concerned that the “point” object is not similar. I have very limited understanding of JSON (being an old fashioned java swing developer) but the fact that the “point” key value pairs can be different – is a problem.

The whole idea for this json stream is to describe a table, with ways of showing progress and to provide a mechanism for asking for “more” from the underlying hardware. Also if you are wondering why, I am sharing this datastream with a thin client (html browser).

So am I correct that this will not easily convert to java objects?

{
  "abort": "abort;session=sessionname",
  "data": {
    "metadata": [
      {
        "protocol": "HTTP",
        "serie": [
          {
            "name": "k1",
            "description": "xDR ID",
            "tooltip": "ASDR Unique Identifier - UiD",
            "type": "int64",
            "key": "1"
          },
          {
            "name": "c1",
            "description": "Answered",
            "tooltip": "Request with Response",
            "type": "bool"
          },
          {
            "name": "c2",
            "description": "Active",
            "tooltip": "Session status: active or closed/down",
            "type": "bool"
          }
        ]
      },
      {
        "protocol": "DNS",
        "serie": [
          {
            "name": "k1",
            "description": "xDR ID",
            "tooltip": "ASDR Unique Identifier - UiD",
            "type": "int64",
            "key": "1"
          },
          {
            "name": "k2",
            "description": "Transaction ID",
            "type": "int64",
            "key": "1",
            "display": "number"
          },
          {
            "name": "k3",
            "description": "Client",
            "tooltip": "Source IP Address",
            "type": "string",
            "key": "1",
            "display": "ip"
          }
        ]
      }
    ],
    "summary": [
      {
        "timestamp": "1331192727",
        "protocol": "HTTP",
        "activity": "www.google.com",
        "results": "OK",
        "point": {
          "k1": "1",
          "c1": "true",
          "c2": "true"
        }
      },
      {
        "timestamp": "1331192727",
        "protocol": "DNS",
        "activity": "www.google.com",
        "results": "OK",
        "point": {
          "k1": "1",
          "k2": "1.1.4.229"
        }
      }
    ]
  },
  "progress": {
    "perc": "100"
  },
  "more": "13,39,1331192727,1331192760,27236,1.1.4.229,limit=1000,session=sessionname"
}

Thank you for any advice you can provide.

-D Klotz

  • 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-31T19:28:40+00:00Added an answer on May 31, 2026 at 7:28 pm

    With GSON, assuming that the class you are deserializing into has fields for all the names that appear in the JSON, the fields not found in the JSON will just be left null:

    https://sites.google.com/site/gson/gson-user-guide#TOC-Finer-Points-with-Objects

    “While deserialization, a missing entry in JSON results in setting the corresponding field in the object to null”

    Things get a little more complicated if arbitrary field names are allowed in the JSON – for example, if Point allows c1, c2, … cn. But you can handle this with a custom deserializer.

    https://sites.google.com/site/gson/gson-user-guide#TOC-Writing-a-Deserializer

    Edit:

    Here’s how you might write a custom deserializer for Point:

    private class DateTimeDeserializer implements JsonDeserializer<Point> {
        public Point deserialize(JsonElement json, Type typeOfT, 
                JsonDeserializationContext context) throws JsonParseException {
            List<PointPart> parts = Lists.newArrayList();
    
            for(Map.Entry<String,JsonElement> entry : 
                    json.getAsJsonObject().entrySet()) {
                char type = ;
                int index = Integer.parseInt(entry.getKey().substring(1)) - 1;
    
                while(parts.size() <= index) {
                    parts.add(new PointPart());
                }
    
                PointPart part = parts.get(index);
                switch(entry.getKey().charAt(0)) {
                case 'c':
                    part.c = entry.getValue().getAsBoolean();
                    break;
                case 'k':
                    part.k = entry.getValue().getAsInt();
                    break;
                }
            }
    
            return new Point(parts);
        }
    }
    
    class Point {
        List<PointPart> parts;
    
        Point(List<PointPart> parts) {
            this.parts = parts;
        }
    }
    
    class PointPart {
        boolean c;
        int k;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pdf that i returned by stream in a json result by
I have a JSON server (WCF REST) with a JSON POST method that accepts
I have a web service that is returning JSON. When testing the program, either
I have JSON string that has nested objects with dynamic names that vary each
I have JSON text that looks like this: { ok: true, totalPages: 256, arReports:
I have JSON that keep changing , I need in android to keep updating
I have a json property that might be null, and I'd prefer to keep
I have a JSON result that has an array of messages: { messages: [
I have not been working with Monotouch (or the iphone for that matter) for
I have setup a basic app which pulls down a JSON stream and displays

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.