scala.util.parsing.json

object JSON

[source: scala/util/parsing/json/JSON.scala]

object JSON
extends Parser
This object provides a simple interface to the JSON parser class. The default conversion for numerics is into a double. If you wish to override this behavior at the global level, you can set the globalNumberParser property to your own (String => Any) function. If you only want to override at the per-thread level then you can set the perThreadNumberParser property to your function. For example:
 val myConversionFunc = {input : String => BigDecimal(input)}
 
 // Global override
 JSON.globalNumberParser = myConversionFunc
 
 // Per-thread override
 JSON.perThreadNumberParser = myConversionFunc
 
Author
Derek Chen-Becker <"java"[email protected]+"chen-becker"+"."+"org">
Values and Variables inherited from Parser
lexical, defaultNumberParser, numberParser
Values and Variables inherited from Parsers
lastNoSuccess
Method Summary
def globalNumberParser : Function1
def globalNumberParser_= (f : Function1) : Unit
The global (VM) default function for converting a string to a numeric value.
def parse (input : java.lang.String) : Option[List[Any]]
Parse the given JSON string and return a list of elements. If the string is a JSON object it will be a list of pairs. If it's a JSON array it will be be a list of individual elements.
def parseFull (input : java.lang.String) : Option[Any]
Parse the given JSON string and return either a List[Any] if the JSON string specifies an Array, or a Map[String,Any] if the JSON string specifies an object.
def perThreadNumberParser : Function1
def perThreadNumberParser_= (f : Function1) : Unit
Defines the function used to convert a numeric string literal into a numeric format on a per-thread basis. Use globalNumberParser for a global override
def resolveType (input : List[Any]) : Any
A utility method to resolve a parsed JSON list into objects or arrays. See the parse method for details.
Methods inherited from Parser
root, jsonObj, jsonArray, objEntry, value, stringVal, number
Methods inherited from ImplicitConversions
flatten2, flatten3, flatten4, flatten5, headOptionTailToFunList
Methods inherited from StdTokenParsers
keyword, numericLit, stringLit, ident
Methods inherited from Parsers
Parser, OnceParser, commit, elem, elem, accept, accept, accept, acceptIf, acceptMatch, acceptSeq, failure, err, success, log, rep, repsep, rep1, rep1, repN, rep1sep, chainl1, chainl1, chainr1, opt, not, positioned, phrase, mkList
Methods inherited from AnyRef
getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
def parse(input : java.lang.String) : Option[List[Any]]
Parse the given JSON string and return a list of elements. If the string is a JSON object it will be a list of pairs. If it's a JSON array it will be be a list of individual elements.
Parameters
input - the given JSON string.
Returns
an optional list of of elements.

def parseFull(input : java.lang.String) : Option[Any]
Parse the given JSON string and return either a List[Any] if the JSON string specifies an Array, or a Map[String,Any] if the JSON string specifies an object.
Parameters
input - the given JSON string.
Returns
an optional list or map.

def resolveType(input : List[Any]) : Any
A utility method to resolve a parsed JSON list into objects or arrays. See the parse method for details.

def globalNumberParser_=(f : Function1) : Unit
The global (VM) default function for converting a string to a numeric value.

def globalNumberParser : Function1

def perThreadNumberParser_=(f : Function1) : Unit
Defines the function used to convert a numeric string literal into a numeric format on a per-thread basis. Use globalNumberParser for a global override

def perThreadNumberParser : Function1