i dont know if JSONObject can dynamically build an object graph..(members please please correct me if this functionality has been added)
i would use AXIOM to add or replace elements to your Object Graph..and then use getChildren to acquire the iterator e.g. java.util.Iterator=ParentNode.GetChildren(); to iterate thru the child nodes.. http://ws.apache.org/commons/axiom/ axis-users mailing list can help with any implementation issues.. HTH Martin ______________________________________________ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Sat, 20 Feb 2010 00:57:52 -0800 > From: cse.k.kart...@gmail.com > To: user@struts.apache.org > Subject: Doubt in json response > > > Hi guys > > I am very new to the forum > > i am providing a json response with recursive looping > > import org.json.simple.JSONObject; > > > public class JsonClass { > public static void main(String args[]) > { > System.out.println(call(5)); > } > public static int call(int i) > { > if(i==1) > { > return 1; > }else > { > JSONObject jsObj=new JSONObject(); > if(i>3) > { > jsObj.put("children", i); > } > jsObj.put("id", i); > System.out.println(jsObj); > return i*call(i-1); > } > } > } > > o/p > > {"id":5,"children":5} > {"id":4,"children":4} > {"id":3} > {"id":2} > > my requirement is to place another child inside 5 as below > {"id":5,"children":5,"anotherchildren":"something"} > {"id":4,"children":4} > {"id":3} > {"id":2} > > do you have any idea > > karthik.k > > -- > View this message in context: > http://old.nabble.com/Doubt-in-json-response-tp27664575p27664575.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/201469227/direct/01/