import com.google.gson.*; interface DecisionTree{} class Leaf implements DecisionTree{ int h; Leaf(int val){ h = val; } } class Compound implements DecisionTree{ int q; DecisionTree y; DecisionTree n; Compound(int q,DecisionTree y,DecisionTree n){ this.q = q; this.y = y; this.n = n; } } class DecisionTreeHead{ DecisionTree decisiontree; DecisionTreeHead(DecisionTree dt){ decisiontree = dt; } } public class DTTest{ public static void main(String[] args){ DecisionTree L0 = new Leaf(0); DecisionTree L1 = new Leaf(1); DecisionTree L2 = new Leaf(2); DecisionTree L3 = new Leaf(3); DecisionTree C3 = new Compound(3,L2,L3); DecisionTree C2 = new Compound(2,L1,C3); DecisionTree C1 = new Compound(1,L0,C2); DecisionTreeHead dt = new DecisionTreeHead(C1); Gson gs = new Gson(); System.out.println(gs.toJson(dt)); } }