public final class XmlJsonConverter
extends java.lang.Object
xml2Json: Converts XML string to JSON, compatible with api-gateway's jdom-based XmlUtils.
json2Xml: Converts JSON string to XML string (generic, no JAXB required).
wrapSoapEnvelope: Wraps XML body in a SOAP 1.1 Envelope with configurable namespaces.
| 限定符和类型 | 方法和说明 |
|---|---|
static java.lang.String |
json2Xml(java.lang.String json,
java.lang.String rootName)
Convert JSON string to XML string.
|
static java.util.Set<java.lang.String> |
parseArrayNodeNames(java.lang.String arrayNodeNamesStr)
Parse comma-separated array node names string into a Set.
|
static com.google.gson.JsonObject |
reParamsDFS(com.google.gson.JsonObject bodyJson,
java.util.Set<java.lang.String> arrayNodeNames)
Process the "reParamsDFS" logic from api-gateway's RestController.
|
static java.lang.String |
wrapSoapEnvelope(java.lang.String jsonBody,
java.util.Map<java.lang.String,java.lang.String> namespaces,
java.lang.String responseElName)
Wrap a JSON response body in a SOAP 1.1 Envelope.
|
static java.lang.String |
xml2Json(java.lang.String xml,
java.util.Set<java.lang.String> arrayNodeNames)
Convert XML string to JSON string.
|
public static java.lang.String xml2Json(java.lang.String xml,
java.util.Set<java.lang.String> arrayNodeNames)
Array node names: nodes listed in arrayNodeNames will always be rendered as JSON arrays even if there is only one occurrence (matching api-gateway's WS_XML_ARRAY config).
xml - the XML stringarrayNodeNames - node names that should always be treated as arrays (comma-separated in config)public static java.lang.String json2Xml(java.lang.String json,
java.lang.String rootName)
json - the JSON stringrootName - the root element name (e.g., "response")public static java.lang.String wrapSoapEnvelope(java.lang.String jsonBody,
java.util.Map<java.lang.String,java.lang.String> namespaces,
java.lang.String responseElName)
Produces output compatible with api-gateway's JaxbXmlUtil.convertToXml(RequestEntity).
jsonBody - the JSON response body stringnamespaces - namespace declarations (prefix → URI), e.g., {"impl": "http://..."}responseElName - the response element name inside soapenv:Body (e.g., "impl:response")public static com.google.gson.JsonObject reParamsDFS(com.google.gson.JsonObject bodyJson,
java.util.Set<java.lang.String> arrayNodeNames)
bodyJson - the form body as a JsonObject (with "xml" field)arrayNodeNames - array node names for XML parsingpublic static java.util.Set<java.lang.String> parseArrayNodeNames(java.lang.String arrayNodeNamesStr)
arrayNodeNamesStr - comma-separated node names (e.g., "order,item,detail")Copyright © 2026 The Apache Software Foundation. All rights reserved.