// to generate the following JSON output | |
// {"identifier":"abbreviation", | |
// "items":[ {"name":"Alaska","label":"Alaska","abbreviation":"AK"}, | |
// {"name":"Wyoming","label":"Wyoming","abbreviation":"WY"} | |
// ]} | |
package com.rubenlaguna.json.flexjson; | |
import flexjson.JSONSerializer; | |
public class WriteFlexjsonDojoTest { | |
public static void main(String[] args) { | |
ItemCollection itemCollection = new ItemCollection("abbreviation"); | |
itemCollection.add(new Item("Alaska", "Alaska", "AK")); | |
itemCollection.add(new Item("Wyoming", "Wyoming", "WY")); | |
JSONSerializer serializer = new JSONSerializer().include("items").exclude("*.class"); | |
String correctJsonStr = serializer.serialize(itemCollection); | |
System.out.println(correctJsonStr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment