Propel API
Class

PropelJSONParser

class PropelJSONParser extends PropelParser

JSON parser.

Converts data between associative array and JSON formats

Methods

string fromArray(array $array)

Converts data from an associative array to JSON.

array toArray(string $data)

Converts data from JSON to an associative array.

listFromArray($data)

from PropelParser
listToArray($data)

from PropelParser
string load(string $path)

Loads data from a file.

from PropelParser
dump(string $data, string $path = null)

Dumps data to a file, or to STDOUT if no filename is given

from PropelParser
static PropelParser getParser(string $type = 'XML')

Factory for getting an instance of a subclass of PropelParser

from PropelParser
string toJSON(array $array)

Alias for PropelJSONParser::fromArray()

array fromJSON(string $data)

Alias for PropelJSONParser::toArray()

Details

at line 26
public string fromArray(array $array)

Converts data from an associative array to JSON.

Parameters

array $array Source data to convert

Return Value

string Converted data, as a JSON string

at line 48
public array toArray(string $data)

Converts data from JSON to an associative array.

Parameters

string $data Source data to convert, as a JSON string

Return Value

array Converted data

in PropelParser at line 40
public listFromArray($data)

Parameters

$data

in PropelParser at line 45
public listToArray($data)

Parameters

$data

in PropelParser at line 57
public string load(string $path)

Loads data from a file.

Executes PHP code blocks in the file.

Parameters

string $path Path to the file to load

Return Value

string The file content processed by PHP

in PropelParser at line 75
public dump(string $data, string $path = null)

Dumps data to a file, or to STDOUT if no filename is given

Parameters

string $data The file content
string $path Path of the file to create

in PropelParser at line 91
static public PropelParser getParser(string $type = 'XML')

Factory for getting an instance of a subclass of PropelParser

Parameters

string $type Parser type, amon 'XML', 'YAML', 'JSON', and 'CSV'

Return Value

PropelParser A PropelParser subclass instance

at line 37
public string toJSON(array $array)

Alias for PropelJSONParser::fromArray()

Parameters

array $array Source data to convert

Return Value

string Converted data, as a JSON string

at line 59
public array fromJSON(string $data)

Alias for PropelJSONParser::toArray()

Parameters

string $data Source data to convert, as a JSON string

Return Value

array Converted data