Package groovy.json
Class JsonSlurperClassic
- java.lang.Object
-
- groovy.json.JsonSlurperClassic
-
public class JsonSlurperClassic extends java.lang.Object
This is the original slurper included in case someone relies on its exact behavior. JSON slurper which parses text or reader content into a data structure of lists and maps.Example usage:
def slurper = new groovy.json.JsonSlurperClassic() 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"
- Since:
- 1.8.0
-
-
Constructor Summary
Constructors Constructor Description JsonSlurperClassic()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
parse(java.io.File file)
Parse a JSON data structure from content within a given File.java.lang.Object
parse(java.io.File file, java.lang.String charset)
Parse a JSON data structure from content within a given File.java.lang.Object
parse(java.io.Reader reader)
Parse a JSON data structure from content from a readerjava.lang.Object
parse(java.net.URL url)
Parse a JSON data structure from content at a given URL.java.lang.Object
parse(java.net.URL url, java.lang.String charset)
Parse a JSON data structure from content at a given URL.java.lang.Object
parse(java.net.URL url, java.util.Map params)
Parse a JSON data structure from content at a given URL.java.lang.Object
parse(java.net.URL url, java.util.Map params, java.lang.String charset)
Parse a JSON data structure from content at a given URL.java.lang.Object
parse(java.util.Map params, java.net.URL url)
Parse a JSON data structure from content at a given URL.java.lang.Object
parse(java.util.Map params, java.net.URL url, java.lang.String charset)
Parse a JSON data structure from content at a given URL.java.lang.Object
parseText(java.lang.String text)
Parse a text representation of a JSON data structure
-
-
-
Method Detail
-
parseText
public java.lang.Object parseText(java.lang.String text)
Parse a text representation of a JSON data structure- Parameters:
text
- JSON text to parse- Returns:
- a data structure of lists and maps
-
parse
public java.lang.Object parse(java.io.Reader reader)
Parse a JSON data structure from content from a reader- Parameters:
reader
- reader over a JSON content- Returns:
- a data structure of lists and maps
-
parse
public java.lang.Object parse(java.io.File file)
Parse a JSON data structure from content within a given File.- Parameters:
file
- File containing JSON content- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.io.File file, java.lang.String charset)
Parse a JSON data structure from content within a given File.- Parameters:
file
- File containing JSON contentcharset
- the charset for this File- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.net.URL url)
Parse a JSON data structure from content at a given URL.- Parameters:
url
- URL containing JSON content- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.net.URL url, java.util.Map params)
Parse a JSON data structure from content at a given URL.- Parameters:
url
- URL containing JSON contentparams
- connection parameters- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.util.Map params, java.net.URL url)
Parse a JSON data structure from content at a given URL. Convenience variant when using Groovy named parameters for the connection params.- Parameters:
params
- connection parametersurl
- URL containing JSON content- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.net.URL url, java.lang.String charset)
Parse a JSON data structure from content at a given URL.- Parameters:
url
- URL containing JSON contentcharset
- the charset for this File- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.net.URL url, java.util.Map params, java.lang.String charset)
Parse a JSON data structure from content at a given URL.- Parameters:
url
- URL containing JSON contentparams
- connection parameterscharset
- the charset for this File- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
parse
public java.lang.Object parse(java.util.Map params, java.net.URL url, java.lang.String charset)
Parse a JSON data structure from content at a given URL. Convenience variant when using Groovy named parameters for the connection params.- Parameters:
params
- connection parametersurl
- URL containing JSON contentcharset
- the charset for this File- Returns:
- a data structure of lists and maps
- Since:
- 2.2.0
-
-