public class JSONXMLUtil extends Object
JSONXMLParser,
JSONXMLSerializer| 限定符和类型 | 字段和说明 |
|---|---|
static Character |
AMP
The Character '&'.
|
static Character |
APOS
The Character '''.
|
static Character |
BANG
The Character '!'.
|
static Character |
EQ
The Character '='.
|
static Character |
GT
The Character '>'.
|
static Character |
LT
The Character '<'.
|
static Character |
QUEST
The Character '?'.
|
static Character |
QUOT
The Character '"'.
|
static Character |
SLASH
The Character '/'.
|
| 构造器和说明 |
|---|
JSONXMLUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static JSONObject |
toJSONObject(JSONObject jo,
String xmlStr,
boolean keepStrings)
转换XML为JSONObject
转换过程中一些信息可能会丢失,JSON中无法区分节点和属性,相同的节点将被处理为JSONArray。
|
static JSONObject |
toJSONObject(String string)
转换XML为JSONObject
转换过程中一些信息可能会丢失,JSON中无法区分节点和属性,相同的节点将被处理为JSONArray。
|
static JSONObject |
toJSONObject(String string,
boolean keepStrings)
转换XML为JSONObject
转换过程中一些信息可能会丢失,JSON中无法区分节点和属性,相同的节点将被处理为JSONArray。
|
static String |
toXml(Object object)
转换JSONObject为XML
|
static String |
toXml(Object object,
String tagName)
转换JSONObject为XML
|
static String |
toXml(Object object,
String tagName,
String... contentKeys)
转换JSONObject为XML
|
public static final Character AMP
public static final Character APOS
public static final Character BANG
public static final Character EQ
public static final Character GT
public static final Character LT
public static final Character QUEST
public static final Character QUOT
public static final Character SLASH
public static JSONObject toJSONObject(String string) throws JSONException
<[ [ ]]> are ignored.string - The source string.JSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(String string, boolean keepStrings) throws JSONException
<[ [ ]]> are ignored.
All values are converted as strings, for 1, 01, 29.0 will not be coerced to numbers but will instead be the exact value as seen in the XML document.string - The source string.keepStrings - If true, then values will not be coerced into boolean or numeric values and will instead be left as stringsJSONException - Thrown if there is an errors while parsing the stringpublic static JSONObject toJSONObject(JSONObject jo, String xmlStr, boolean keepStrings) throws JSONException
jo - JSONObjectxmlStr - XML字符串keepStrings - 如果为true,则值保持String类型,不转换为数字或booleanJSONException - 解析异常public static String toXml(Object object) throws JSONException
object - JSON对象或数组JSONException - JSON解析异常public static String toXml(Object object, String tagName) throws JSONException
object - JSON对象或数组tagName - 可选标签名称,名称为空时忽略标签JSONException - JSON解析异常public static String toXml(Object object, String tagName, String... contentKeys) throws JSONException
object - JSON对象或数组tagName - 可选标签名称,名称为空时忽略标签contentKeys - 标识为内容的key,遇到此key直接解析内容而不增加对应名称标签JSONException - JSON解析异常Copyright © 2023. All rights reserved.