@Deprecated public class JsonParser extends Object
JSONObject 和JSONArray| Constructor and Description |
|---|
JsonParser()
Deprecated.
默认构造函数,如果您需要配置jsonPath,请调用
setJsonPath(String); 或配置jsonObject,请调用setJsonObject(String)或setJsonObject(JSONObject) |
JsonParser(com.alibaba.fastjson.JSONObject jsonObject)
Deprecated.
自动配置jsonObject
|
JsonParser(String jsonPath)
Deprecated.
自动配置jsonPath,根据JSON文件路径读取json并转换为JSONObject
|
JsonParser(String json,
boolean isPretty)
Deprecated.
自动配置jsonObject
|
JsonParser(URL url)
Deprecated.
读取URL中的内容,并将结果转换成JSON
|
| Modifier and Type | Method and Description |
|---|---|
void |
arrayAdd(String path,
Object... values)
Deprecated.
数组追加数组
|
void |
clearCache()
Deprecated.
清除JSON缓存
|
boolean |
contains(String path)
Deprecated.
是否包含某个对象
|
boolean |
containsValue(String path,
Object value)
Deprecated.
是否包含某个值
|
Object |
eval(String path)
Deprecated.
根据路径获取对象
|
com.alibaba.fastjson.JSONArray |
getArray(String key)
Deprecated.
获取JsonArray
|
com.alibaba.fastjson.JSONArray |
getArrayUseEval(String key)
Deprecated.
获取JsonArray
|
boolean |
getBooleanUseEval(String key)
Deprecated.
获取一个boolean
|
int |
getCacheSize()
Deprecated.
获取当前缓存大小
|
double |
getDouble(String key)
Deprecated.
获取Double
|
double |
getDoubleUseEval(String key)
Deprecated.
获取Double
|
int |
getInteger(String key)
Deprecated.
获取Integer
|
int |
getIntegerUseEval(String key)
Deprecated.
获取Integer
|
com.alibaba.fastjson.JSONObject |
getJsonObject()
Deprecated.
获取当前解析的JsonObject
|
String |
getJsonPath()
Deprecated.
获取当前json文件的绝对路径
|
int |
getMaxCache()
Deprecated.
获取最大缓存值
|
com.alibaba.fastjson.JSONObject |
getObject(String key)
Deprecated.
获取JsonObject
|
com.alibaba.fastjson.JSONObject |
getObjectUseEval(String key)
Deprecated.
获取JsonObject
|
String |
getString(String key)
Deprecated.
获取String
|
String |
getStringUseEval(String key)
Deprecated.
获取String
|
boolean |
hasJsonObject()
Deprecated.
是否已经赋值
|
boolean |
remove(String path)
Deprecated.
移除某个路径
|
boolean |
set(String path,
Object value)
Deprecated.
根据路径设置值
|
void |
setJsonObject(com.alibaba.fastjson.JSONObject jsonObject)
Deprecated.
配置JsonObject
|
void |
setJsonObject(String json)
Deprecated.
配置JsonObject
|
void |
setJsonPath(String jsonPath)
Deprecated.
配置jsonPath,权限JSON文件路径读取json并转换为JSONObject
|
void |
setJsonPath(URL url)
Deprecated.
设置JSON对应的URL
|
void |
setMaxCache(int maxCache)
Deprecated.
设置最大缓存值
|
int |
size(String path)
Deprecated.
获取大小
|
String |
toString()
Deprecated.
重写了toString方法,返回并格式化当前解析的JSONObject
|
public JsonParser()
setJsonPath(String); 或配置jsonObject,请调用setJsonObject(String)或setJsonObject(JSONObject)public JsonParser(com.alibaba.fastjson.JSONObject jsonObject)
jsonObject - JSONObjectpublic JsonParser(String jsonPath) throws IOException
jsonPath - JSON文件的路径IOException - 异常public JsonParser(URL url) throws IOException
url - 网络链接IOException - 异常public JsonParser(String json, boolean isPretty)
json - Json文本isPretty - 是否是格式化的Json,不清楚的话请设置为falsepublic boolean hasJsonObject()
Booleanpublic boolean set(String path, Object value)
path - 路径语法value - 值对象public boolean getBooleanUseEval(String key)
key - 路径Booleanpublic boolean contains(String path)
public void arrayAdd(String path, Object... values)
path - 路径语法values - 数组public boolean remove(String path)
path - 路径语法public com.alibaba.fastjson.JSONObject getObject(String key)
key - 例如:countryJSONObjectpublic com.alibaba.fastjson.JSONObject getObjectUseEval(String key)
key - 例如:countryJSONObjectpublic com.alibaba.fastjson.JSONArray getArray(String key)
key - 例如:country.provinceJSONArraypublic com.alibaba.fastjson.JSONArray getArrayUseEval(String key)
key - 例如:country.provinceJSONArraypublic String getString(String key)
key - 例如:country.province[13].nameStringpublic String getStringUseEval(String key)
key - 例如:country.province[13].nameStringpublic int getIntegerUseEval(String key)
key - 例如:country.province[13].peopleNumsIntegerpublic double getDoubleUseEval(String key)
key - 例如:country.province[13].areaDoublepublic void setJsonPath(URL url) throws IOException
url - 网络链接IOException - 异常public void setJsonPath(String jsonPath) throws IOException
jsonPath - JSON文件的路径IOException - 异常public com.alibaba.fastjson.JSONObject getJsonObject()
JSONObjectpublic void setJsonObject(String json)
json - 传入json文本,自动转换为JsonObjectpublic void setJsonObject(com.alibaba.fastjson.JSONObject jsonObject)
jsonObject - JSONObjectpublic String toString()
public int getMaxCache()
Integerpublic void setMaxCache(int maxCache)
maxCache - Integerpublic int getCacheSize()
Integerpublic void clearCache()
Copyright © 2018. All rights reserved.