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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:27:25+00:00 2026-06-09T08:27:25+00:00

Edit: I’ve changed the style of the json file to make it simpler as

  • 0

Edit: I’ve changed the style of the json file to make it simpler as I couldn’t work with the older version. I need to be able to create an array of targets in java where each element in the array has its name as the value of Target_Name. I also need to be able to merge together repeating target names that have different object names. So basically I want a target array and within each element I want to have an array of objects holding Type, Pin_number and capabilities.

I know I may have to create a Target list class and within that variables for target name and everything else. I have tried something like that before but I had trouble figuring out how it would work.

    {
"Targets": [
    {
        "Target_Name": "----",
        "Object_Name": "----",
        "Type": "----",
        "Pin_Number": "----",
        "Capabilities": "----"
    },
    {
        "Target_Name": "----",
        "Object_Name": "----",
        "Type": "----",
        "Pin_Number": "----",
        "Capabilities": "----"
    },
    {
        "Target_Name": "----",
        "Object_Name": "----",
        "Type": "----",
        "Pin_Number": "----",
        "Capabilities": "----"
    },
    {
        "Target_Name": "----",
        "Object_Name": "----",
        "Type": "----",
        "Pin_Number": "----",
        "Capabilities": "----"
    }
]

}

  • 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-06-09T08:27:26+00:00Added an answer on June 9, 2026 at 8:27 am

    It’s pretty straight forward, following is some code how to load and read nodes. It will help you to find out how to query your data.

    Reader reader = null;
    InputStream stream = context.getResources()
        .openRawResource(R.raw.json_file);
    reader = new BufferedReader(new InputStreamReader(stream), 8092);
    
    // parse json
    JsonParser parser = new JsonParser();
    JsonObject jsonObj = (JsonObject)parser.parse(reader);
    

    // your json parsing is going to look like following

    JsonArray targets= jsonObj.getAsJsonArray("Targets");
    
    List<Target> targetList = new ArrayList<Target>(); 
    for (JsonElement target: targets) {
    
        JsonObject targetObject = target.getAsJsonObject();
        String targetName= targetObject.get("Target_Name").getAsString();
        ....//get the rest
    
        // create target object
        targetList.add(new Target(targetName, ....));
    }
    

    // Examples of how to read values and query objects

    for (Entry<String, JsonElement> entry : rootElem.entrySet())
    {
        int key = Integer.parseInt(entry.getKey());
        JsonObject jsonObject = entry.getValue().getAsJsonObject();
    }
    
    
    // get integer element
    int key = Integer.parseInt(entry.getKey());
    
    // get child object
    JsonObject jsonObject = entry.getValue().getAsJsonObject();
    
    // get string element           
    String title = jsonObject.get("Object_Name").getAsString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Simple version of the question: I want to create server variables in the
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
EDIT: Parsed the array completely (it contained unparsed JSON!) array(22) { [0]=> array(4) {
EDIT: Changed as I have a different issue with the same code 2nd Edit:
EDIT: void print(const int *v, const int size) { FILE *fpIn; fpIn = fopen(char-array.txt,
EDIT: I'll try and make it clearer sorry for the confusion. I have two
EDIT: solved, I know how but I don't understand why. I changed variables declaration
Edit: To those who need to blit an image(i.e. copy a part of a
Edit 4: I was finally able to solve my own issue. See checkmark answer
EDIT What small things which are too easy to overlook do I need to

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.