public class JSONWrapper extends Object
Define a type to wrap a JSON string
| Constructor and Description |
|---|
JSONWrapper(String str)
Construct a JSONWrapper with a JSON string.
|
| Modifier and Type | Method and Description |
|---|---|
List<Object> |
getArray()
Return a List of object contained in the JSON array.
|
Map<String,Object> |
getObject()
Return a Map of String and object contained in the JSON object.
|
boolean |
isArray()
Return true if the underline JSON data is an array
|
static JSONWrapper |
wrap(String s)
Parse the string and return the JSONWrapper
|
public JSONWrapper(String str)
Construct a JSONWrapper with a JSON string. If the string is not valid JSON, then a RuntimeException will thrown out
str - public boolean isArray()
Return true if the underline JSON data is an array
public List<Object> getArray()
Return a List of object contained in the JSON array.
If the data is not a JSON array then a ClassCastException will be thrown outpublic Map<String,Object> getObject()
Return a Map of String and object contained in the JSON object.
If the data is a JSON array then a ClassCastException will be thrown outpublic static JSONWrapper wrap(String s)
Parse the string and return the JSONWrapper
s - Copyright © 2017–2021 OSGL (Open Source General Library). All rights reserved.