The JSONParser structure implements a parser for the
JSON.value type.
Synopsis
structure JSONParser
Interface
type source
val openStream : TextIO.instream -> source
val openFile : string -> source
val openString : string -> source
val close : source -> unit
val parse : source -> JSON.value
val parseFile : string -> JSON.value
Description
type source-
The abstract type of JSON input sources. Note that this type is the same as
JSONStreamParser.source.
val openStream : TextIO.instream → source-
openStream inSreturns a input source for the given input stream.
val openFile : string → source-
openStream filereturns a input source for the given file. This function opens an input stream for reading from the file, so one should make sure to callcloseon the source once all of the JSON values have been read from the file. val openString : string → source-
openStream sreturns a input source for the given string.
val close : source → unit-
close srccloses the input source, which has the effect of marking the source as closed. Furthermore, ifsrcwas created by a call toopenFile, then the underlying input stream that was created for the file is closed. This function does not close the input stream for sources created byopenStream
val parse : source -> JSON.value-
parse srcparses a JSON value from the input sourcesrc. Ifsrcis closed or if there is a syntax error, then theFailexception is raised. val parseFile : string -> JSON.value-
parse fparses a JSON value from the text filef. If there is a syntax error, then theFailexception is raised. This function can also raise theIoexception if there is an error openingf. Note that this function will only parse a single JSON value from the file; to parse multiple values, one should used theparsefunction with a source created byopenFile.