Convert a Java map to JSON string
public static String convertMapToJSONString(Map<String, Object> mapToConvert) {
String returnString = "";
try {
StringWriter out = new StringWriter();
JSONValue.writeJSONString(mapToConvert, out);
returnString = out.toString();
} catch (Exception e) {
}
return returnString;
}
do not forget to import ,
import org.json.simple.JSONValue;
Post a Comment
0 Comments