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.6, prepared
MODULE Public.Parser |
Modules JSON2
|
|
MODULE Public.Parser.JSON2 |
Methods parse() render() validate()
|
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).
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
- 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.
-
Constants
constant
Public.Parser.JSON2.ASCII_ONLY
constant
Public.Parser.JSON2.ASCII_LESS
constant
Public.Parser.JSON2.HUMAN_READABLE
- Description
May be passed to render() as the second argument. Multiple
flags may be used by ORing them bitwise (ASCII_LESS includes
ASCII_ONLY).
-
Render all Unicode characters in strings with value
bigger than 255 using the \u escape.
-
Renders all Unicode character in strings with value outside
of 32 - 126 using the \u escape.
-
Uses spaces and tabs to create easy to read output.
-
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
Takes a native pike data structure (no multisets allowed and all mappings
need strings as keys) and renders it into a string/String.Buffer.
- Throws
Throws an exception in case the data contains multisets or a
mapping with non-string keys.
-
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.
|
|