Here you can find the source of sanitizeJson4XML(String jsonString)
Parameter | Description |
---|---|
jsonString | - the JSON string to process. |
public static String sanitizeJson4XML(String jsonString)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww . j a v a 2s. co m*/ * sanitizeJson4XML - Sanitize a JSON string so it converts to XML without error. * * @param jsonString - the JSON string to process. * @return - an "XML safe" JSON string. * */ public static String sanitizeJson4XML(String jsonString) { // Remove leading & trailing whitespace jsonString = jsonString.trim(); // Handle anonymous object results if (!jsonString.startsWith("{")) { jsonString = "{\"Anonymous\":" + jsonString + "}"; } return jsonString; } }