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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:36:04+00:00 2026-05-27T15:36:04+00:00

I have a JSON tree structure that is generated dinamically, this means the keys

  • 0

I have a JSON tree structure that is generated dinamically, this means the keys and the structure are unknown and it can change in every request, the only common property in every object are the oldValue and newValue keys…

the JSON looks like this:

{
"obj1": 
    {"oldValue": "foo", "newValue": "foofoo"},
"obj2": 
    {"obj2_1": 
        {"oldValue": null, "newValue": "foo"}
    },
    {"obj2_2": 
        {"obj2_2_1": 
            {"oldValue": "foo", "newValue": "foofoo"}           
        },
        {"obj2_2_2": 
            {"oldValue": "foo1", "newValue": null}          
        }
    }
}

How can I load this data in a TreeGrid dinamically? Is it possible to get to the deepest key using XPath?

  • 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-27T15:36:04+00:00Added an answer on May 27, 2026 at 3:36 pm

    I came to the conclusion that is just not possible with SmartGWT because of the fact that, in SmartGWT components that can handle hierarchical data, you need to specify a parent key as an attribute, wich is not very practical (IMHO)…

    Now the solution: The best alternative to this is to use the GWT core widgets Tree and TreeItem, with TreeItem you can attach items dinamically, so I loaded the json data into a JSONObject and added the nodes recursively.

    Below the tree nodes loading process:

    private void loadTreeNodes(JSONObject jsonObject, TreeItem parent) {        
        for (String key: jsonObject.keySet()) {                
            JSONValue jsonValue = jsonObject.get(key);    
            TreeItem item = new TreeItem("<b>" + key + "</b> ");
            parent.addItem(item);
    
            if (jsonValue != null) {
                if (jsonValue.isObject() != null) {
                    loadTreeNodes(jsonValue.isObject(), item);
                } else if (jsonValue.isArray() != null) {
    
                } else {
                    if ("oldValue".equals(key)) {
                        item.setHTML("<b>before:</b> " + jsonValue.toString());
                    } else {
                        item.setHTML("<b>after:</b> " + jsonValue.toString());
                    }                    
                }
            } else {
                item.setText("<b>" + item.getText() + ":</b> null");
            }
        }        
    }
    

    I loaded the json data like this:

    JavaScriptObject obj = JSON.decode(jsonData);
    JSONObject jsonObject = new JSONObject(obj);
    

    Any comments are welcome!

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

Sidebar

Related Questions

I have a dijit.Tree that's populated by a ItemFileReadStore using JSON. Because of our
I'd like to create a tree structure from JSON, but with multiple columns that
Can't seem to figure this out. I'm attempting JSON tree manipulation in GSON, but
I have a JSON tree that contains nodes and children - the format is:
I have a JSON array with ActiveRecord objects. These objects can be reconstructed using
I have one JSON that is coming in a string format. I need to
I have two JSON objects with the same structure and I want to concat
I have a JSON result that contains numerous records. I'd like to show the
I have some JSON returned to the browser like this product: { Title: School
We have a JSON response which can contain null values (e.g. { myValue: null

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.