001 /* Generated By:JJTree: Do not edit this line. ASTobject.java */ 002 003 package net.sourceforge.javajson.parser; 004 005 import net.sourceforge.javajson.JsonObject; 006 007 public class ASTobject extends SimpleNode { 008 JsonObject json = new JsonObject(); 009 010 public ASTobject(int id) { 011 super(id); 012 } 013 014 public ASTobject(JsonParser p, int id) { 015 super(p, id); 016 } 017 018 @Override 019 protected void interpret() { 020 if (children != null) { 021 for (int i = 0; i < children.length; i++) { 022 if (children[i] instanceof SimpleNode) { 023 SimpleNode node = (SimpleNode) children[i]; 024 node.interpret(); 025 } 026 } 027 } 028 029 ((SimpleNode) parent).push(json); 030 } 031 032 @Override 033 protected void push(Object o) { 034 // System.out.println("pushing to json object: " + 035 // o.getClass().getSimpleName()); 036 if (o instanceof TMember) { 037 TMember m = (TMember) o; 038 if (m.value instanceof ASTarray) 039 json.put(m.key, ((ASTarray) m.value).array); 040 else 041 json.put(m.key, m.value); 042 } 043 } 044 }