PHP Class Peekmo\JsonPath\JsonStore

Copyright (c) 2007 Stefan Goessner (goessner.net) Licensed under the MIT (MIT-LICENSE.txt) licence. Modified by Axel Anceau
Show file Open project: peekmo/jsonpath Class Usage Examples

Public Methods

Method Description
__construct ( string | array | stdClass $data )
add ( string $parentexpr, mixed $value, string $name = "" ) : boolean Adds one or more elements matching the given json path expression
get ( string $expr, boolean $unique = false ) : array Gets elements matching the given JsonPath expression
remove ( string $expr ) : boolean Removes all elements matching the given jsonpath expression
set ( string $expr, mixed $value ) : boolean Sets the value for all elements matching the given JsonPath expression
setData ( string | array | stdClass $data ) Sets JsonStore's manipulated data
toArray ( ) : array Returns the given json string to array
toObject ( ) : stdClass Returns the given json string to object
toString ( ) : string JsonEncoded version of the object

Private Methods

Method Description
normalizedFirst ( $expr )

Method Details

__construct() public method

public __construct ( string | array | stdClass $data )
$data string | array | stdClass

add() public method

Adds one or more elements matching the given json path expression
public add ( string $parentexpr, mixed $value, string $name = "" ) : boolean
$parentexpr string JsonPath expression to the parent
$value mixed Value to add
$name string Key name
return boolean returns true if success

get() public method

Gets elements matching the given JsonPath expression
public get ( string $expr, boolean $unique = false ) : array
$expr string JsonPath expression
$unique boolean Gets unique results or not
return array

remove() public method

Removes all elements matching the given jsonpath expression
public remove ( string $expr ) : boolean
$expr string JsonPath expression
return boolean returns true if success

set() public method

Sets the value for all elements matching the given JsonPath expression
public set ( string $expr, mixed $value ) : boolean
$expr string JsonPath expression
$value mixed Value to set
return boolean returns true if success

setData() public method

Sets JsonStore's manipulated data
public setData ( string | array | stdClass $data )
$data string | array | stdClass

toArray() public method

Returns the given json string to array
public toArray ( ) : array
return array

toObject() public method

Returns the given json string to object
public toObject ( ) : stdClass
return stdClass

toString() public method

JsonEncoded version of the object
public toString ( ) : string
return string