|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.json.JsonSlurper
public class JsonSlurper
JSON slurper which parses text or reader content into a data structure of lists and maps.
Example usage:
def slurper = new JsonSlurper()
def result = slurper.parseText('{"person":{"name":"Guillaume","age":33,"pets":["dog","cat"]}}')
assert result.person.name == "Guillaume"
assert result.person.age == 33
assert result.person.pets.size() == 2
assert result.person.pets[0] == "dog"
assert result.person.pets[1] == "cat"
Method Summary | |
---|---|
java.lang.Object
|
parse(java.io.Reader reader)
Parse a JSON data structure from content from a reader |
java.lang.Object
|
parseText(java.lang.String text)
Parse a text representation of a JSON data structure |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Method Detail |
---|
public java.lang.Object parse(java.io.Reader reader)
reader
- reader over a JSON content
public java.lang.Object parseText(java.lang.String text)
text
- JSON text to parse
Groovy Documentation