加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

fastjson文档解读——下篇

发布时间:2020-12-16 19:02:25 所属栏目:百科 来源:网络整理
导读:com.alibaba.fastjson.JSONArray 有一些基本的数组操作方法,就像操作List数组一样操作JSONArray就可以。 添加元素: void add(int index,Object element) boolean add(Object e) boolean addAll(Collection? extendsObject c) boolean addAll(int index,Col

com.alibaba.fastjson.JSONArray

有一些基本的数组操作方法,就像操作List数组一样操作JSONArray就可以。

添加元素:

void add(int index,Object element)

boolean add(Object e)

boolean addAll(Collection<? extendsObject> c)

boolean addAll(int index,Collection<?extends Object> c)

获取元素:

Object get(int index)

BigDecimal getBigDecimal(int index)

BigInteger getBigInteger(int index)

Boolean getBoolean(int index)

boolean getBooleanValue(int index)

Byte getByte(int index)

byte getByteValue(int index)

Type getComponentType()

Date getDate(int index)

Double getDouble(int index)

double getDoubleValue(int index)

Float getFloat(int index)

float getFloatValue(int index)

Integer getInteger(int index)

int getIntValue(int index)

JSONArray getJSONArray(int index)

JSONObject getJSONObject(int index)

Long getLong(int index)

long getLongValue(int index)

<T> T getObject(int index,Class<T> clazz)

Object getRelatedArray()

Short getShort(int index)

short getShortValue(int index)

Date getSqlDate(int index)

String getString(int index)

Timestamp getTimestamp(int index)

Iterator:

Iterator<Object> iterator()

int lastIndexOf(Object o)

ListIterator<Object> listIterator()

ListIterator<Object> listIterator(intindex)

删除:

Object remove(int index)

boolean remove(Object o)

boolean removeAll(Collection<?> c)

boolean retainAll(Collection<?> c)

其他重要方法:

void clear():清空数组。即遍历数组,移除其中所有的键值,并置为null。

Object clone():克隆。

Boolean contains(Object o):判断是否包含某个元素。

Boolean containsAll(Collection<?> c):判断是否包含某个集合

Boolean equals(Object obj):判断是否与所传对象相同。equals只比较值。

com.alibaba.fastjson.JSONObject

添加元素

Object put (String key,Object value)

void putAll(Map<? extends String,? extendsObject> m)

取值:

Object get(Object key)

BigDecimal getBigDecimal(String key)

BigInteger getBigInteger(String key)

Boolean getBoolean(String key)

boolean getBooleanValue(String key)

Byte getByte(String key)

byte[] getBytes(String key)

byte getByteValue(String key)

Date getDate(String key)

Double getDouble(String key)

double getDoubleValue(String key)

Float getFloat(String key)

float getFloatValue(String key)

Integer getInteger(String key)

int getIntValue(String key)

JSONArray getJSONArray(String key)

JSONObject getJSONObject(String key)

Long getLong(String key)

long getLongValue(String key)

<T> T getObject(Stringkey,Class<T> clazz)

Short getShort(String key)

short getShort(String key)

Date getSqlDate(String key)

String getString(String key)

Timestamp getTimestamp(String key)

删除:

Object remove (Object key)

其他重要方法:

void clear():清空

Object clone():克隆

boolean containsKey(Object key):是否包含某键

boolean containsValue(Object value):是否包含某值

set<map.Entry<String,Object>>entrySet():取键值对

boolean equals (Object obj):判断是否相等

int hashCode():返回JSONObject对象的hashCode

Object invoke(Object proxy,Method method,Object[] args):

boolean isEmpty():判断是否为空

Set<String> keyset():取键的集合

int size():JSONObject的大小

Collection <Object> values():取值的集合

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读