Modules
ADT Database GTK2 GUI IP PiJAX Public Sql Stdio Subversion System Tools Xosd lua v4l2 wx
Recent Changes
Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0
Popular Downloads
Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48
|
Pike Module Reference: module version 0.7, prepared
MODULE Public.Parser |
Modules JSON2
|
|
MODULE Public.Parser.JSON2 |
Methods parse() parse_utf8() render() render_utf8() validate() validate_utf8()
|
Description
This module contains a parser to parse JSON into native pike types. The parser has been written
in c using ragel (http://www.cs.queensu.ca/~thurston/ragel/).
The parser is supposed to handle Unicode strings (internally 8, 16 and 32 bit wide strings that is).
There are special functions for handling utf8 encoded Unicode strings.
Have a look at http://www.json.org or http://www.ietf.org/rfc/rfc4627.txt?number=4627 for
information about what JSON is.
-
Variables
object Public.Parser.JSON2.null object Public.Parser.JSON2.true object Public.Parser.JSON2.false object Public.Parser.JSON2.Unicode
- Description
Objects representing the three JSON literals null, false
and true. They should behave as exprected in boolean context.
null can be used as the Integer value 0 in addition and
multiplication.
-
Constant HUMAN_READABLE
constant
Public.Parser.JSON2.HUMAN_READABLE
- Description
May be passed to render() and render_utf8() as a flag. Makes output
readable by inserting spaces and newlines.
-
Method validate
int Public.Parser.JSON2.validate(string s)
- Description
Takes a string and checks if it is valid JSON.
- Returns
In case the string contains valid JSON -1 is returned. It is then guarenteed to be parsed
without errors by parse().
In case the string is not valid JSON, the integer position inside the string
where the error occures is returned.
-
Method parse
array|mapping|string|float|int Public.Parser.JSON2.parse(string s)
- Description
Parses a JSON-formatted string and returns the corresponding pike data type.
- Throws
Throws an exception in case the data contained in s is not valid
JSON.
-
Method validate_utf8
int Public.Parser.JSON2.validate_utf8(string s)
- Description
Takes a utf8 encoded string and checks if it is valid JSON.
- Returns
In case the string contains valid JSON -1 is returned. It is then guarenteed to be parsed
without errors by parse().
In case the string is not valid JSON, the integer position inside the string
where the error occures is returned.
-
Method parse_utf8
array|mapping|string|float|int Public.Parser.JSON2.parse_utf8(string s)
- Description
Parses a utf8 encoded JSON-formatted string and returns the corresponding pike data type.
Should give the same results as Public.Parser.JSON2.parse(utf8_to_string(s)).
- Throws
Throws an exception in case the data contained in s is not valid
JSON.
-
Method render
string Public.Parser.JSON2.render(mixed data, int|void flags) object(String.Buffer) Public.Parser.JSON2.render(mixed data, int flags, object(String.Buffer) buf)
- Description
Encodes a native pike data structure into a Unicode string.
- Note
Multisets and mappings with non-string keys are not supported
by JSON.
- Throws
Throws an exception in case the data contains multisets or a
mapping with non-string keys.
-
Method render_utf8
string Public.Parser.JSON2.render_utf8(mixed data, int|void flags) object(String.Buffer) Public.Parser.JSON2.render_utf8(mixed data, int flags, object(String.Buffer) buf)
- Description
Encodes a native pike data structure into a UTF8 encoded Unicode string.
- Note
Multisets and mappings with non-string keys are not supported
by JSON.
- Throws
Throws an exception in case the data contains multisets or a
mapping with non-string keys.
|
|