Created
April 21, 2011 18:32
-
-
Save searls/935184 to your computer and use it in GitHub Desktop.
Mapping Java to JSON in a jdk1.4 compatible way
This file contains hidden or 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
public String convert(List<Map<String, Object>> queryResults) { | |
//json-simple - WINNAR! | |
return JSONValue.toJSONString(queryResults); | |
//flexjson - fail - requires java.lang.Enum | |
// return new JSONSerializer().serialize(queryResults); | |
//Jackson - fail - requires java.io.Closeable | |
// try { | |
// return new ObjectMapper().writeValueAsString(queryResults); | |
// } catch (Exception e) { | |
// throw new RuntimeException(e); | |
// } | |
//Gson - fail - requires java.lang.reflect.Type | |
// return new Gson().toJson(queryResults); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment