Skip to content

Instantly share code, notes, and snippets.

@mkristian
Created September 28, 2011 13:13
Show Gist options
  • Save mkristian/1247897 to your computer and use it in GitHub Desktop.
Save mkristian/1247897 to your computer and use it in GitHub Desktop.
[INFO] {"phone_number":null, "delivery":true, "delivery_address":["3434 Pinerun Ave.","Tampa, FL 33734"], "pizzas":[{"crust":"thin", "quantity":1, "size":16, "toppings":["ham","pineapple"]},{"crust":"thin", "quantity":1, "size":16, "toppings":["extra cheese"]}]}
public class MyEntryPoint implements EntryPoint {
public static class Pizza {
public String crust;
public int quantity;
public int size;
public List<String> toppings = new ArrayList<String>();
}
public static class PizzaOrder {
public String phone_number;
public boolean delivery;
public List<String> delivery_address = new ArrayList<String>(4);
public List<Pizza> pizzas = new ArrayList<Pizza>(10);
}
public interface PizzaOrderJED extends JsonEncoderDecoder<PizzaOrder> {
}
/**
* This is the entry point method.
*/
public void onModuleLoad() {
PizzaOrder order = new PizzaOrder();
order.delivery = true;
order.delivery_address.add("3434 Pinerun Ave.");
order.delivery_address.add("Tampa, FL 33734");
Pizza pizza = new Pizza();
pizza.crust = "thin";
pizza.quantity = 1;
pizza.size = 16;
pizza.toppings.add("ham");
pizza.toppings.add("pineapple");
order.pizzas.add(pizza);
pizza = new Pizza();
pizza.crust = "thin";
pizza.quantity = 1;
pizza.size = 16;
pizza.toppings.add("extra cheese");
order.pizzas.add(pizza);
PizzaOrderJED jed = GWT.create(PizzaOrderJED.class);
System.out.println(jed.encode(order).toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment