Created
August 2, 2010 19:52
-
-
Save ecerulm/505206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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