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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:43:23+00:00 2026-06-12T14:43:23+00:00

I have a tree, to be displayed on the screen, which is basically a

  • 0

I have a tree, to be displayed on the screen, which is basically a JSON object. I want to send this JSON object to the Java class as a request parameter.

Following is a sample of the JSON object:

// Root node
var rootNode = { Content: "Root", Nodes:[] };
// First Level
rootNode.Nodes[0] = { Content: "Employee Code", navigationType: "0"};
rootNode.Nodes[1] = { Content: "Problem Area", navigationType: "1" };
// Second Level
rootNode.Nodes[1].Nodes = [{ Content : "ACC-HO", Collapsed: true},
                           { Content : "ACC-SALES" },
                           { Content : "BUSI. HEAD", ToolTip: "Click ME!" },
                           { Content : "CEO"}
                          ];

Now the plugin, which creates this tree out of the JSON object, stores the reference of the Parent Node in each of the nodes. Hence this results in a circular reference where a node stores reference of its children and each child node stores the reference of its Parent

Due to this I am unable to use JSON.stringify(rootNode)

I want to send the rootNode object as a request parameter using Ajax. I have done the following:

$.ajax({
    type : "POST",
    url : "treeDemo_!saveTree",
            data: {treeObject: JSON.stringify(rootNode) },
            success : function(resp) {      
        alert('success');
    }
});

But as I mentioned, JSON.stringify doesnt work in my case. So can anyone suggest an alternative way to send the JSON object as a request parameter which I can receive in the Java code and process further?

  • 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-12T14:43:25+00:00Added an answer on June 12, 2026 at 2:43 pm

    A solution, if you can’t clean the plugin, is to clone the rootNode object and in the process don’t copy the ‘Parent’ property :

    function goclone(source) {
        if (Object.prototype.toString.call(source) === '[object Array]') {
            var clone = [];
            for (var i=0; i<source.length; i++) {
                clone[i] = goclone(source[i]);
            }
            return clone;
        } else if (typeof(source)=="object") {
            var clone = {};
            for (var prop in source) {
                if (source.hasOwnProperty(prop) && prop!='Parent') {
                    clone[prop] = goclone(source[prop]);
                }
            }
            return clone;
        } else {
            return source;
        }
    }
    
    var serializableRootNode = goclone(rootNode);
    

    The serializableRootNode doesn’t contain the ‘Parent’ properties.

    Adapt the code if the parent reference isn’t called exactly ‘Parent’.

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

Sidebar

Related Questions

I have a tree in which i want the onOpen and onClose to be
I have a Tree node. I want an image to be displayed beside the
Am trying to have a tree when a button is clicked. Basically this view
I am trying to have a tree display custom data that looks like this.
I have tree like following example, where every leaf is object. [1] |--[2] |
I have a tree walker like this: function: ^(FUNCTION_TOK fcname=IDENTIFIER param=functionParameters*){ a_param_arrayList.add(param); } ;
I have an own Tree object implemented in PHP. Say we have a tree
I have a tree control and I want to give the user the ability
I have a UINavigationController onto which I push a 'loading screen' UIViewController whilst I
I have a tree which is dynamic (where i can add and remove tree

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.