Json Library



( ZN >= 2.0.0 )

Json Library JavaScript Object Notation   is used to express JavaScript Object Notation (JSON) . PHP Json plugin Douglas Crockford. The ZN Json library is created by making the json_ * functions bound to this extension object-based.

 

# Methods


String encode ( Mixed $ data , String $ type = 'unescapedUnicode' )
Mixed decode ( String $ data , Bool $ array = false , Int $ length = 512 )
Array decodeArray ( String $ data , Int $ length = 512 )
Object decodeObject ( String $ data , Int $ length = 512 )
Bool check ( String $ data )
Int errno ( Void )
String error ( Void )

 

# Encode ( ZN >= 2.0.0 )


Converts data received as an array to private data. Especially in database queries, you can use it when you want to save more than one kind of data in a column of a table.

Parameters

Mixed $ data Data to be stored in a special format.
String $ type = 'unescapedUnicode' Mask type.
Options hexQuot , hexTag , hexAmp , hexApos , forceObject
return String

Use of

echo Json::encode(['foo' => 'Foo', 'bar' => 'Bar']);
{ "Foo": "foo", "bar": "bar"} 

 

# Decode ( ZN >= 2.0.0 )


Used to restore the encrypted data.

Parameters

String $ data The data to be resolved in custom format.
Bool $ array = false false , true Whether it's an array or an object type.
Int $ length = 512 Data length.
return Mixed

Use of

$encode = Json::encode(['foo' => 'Foo', 'bar' => 'Bar']);

output(Json::decode($encode)->foo);
output(Json::decode($encode, true)['foo']);
Foo
Foo

 

# DecodeArray ( ZN >= 2.0.0 )


Used to fetch the encrypted data in the form of an array.

Parameters

String $ data The data to be resolved in custom format.
Int $ length = 512 Data length.
return Array

Use of

$encode = Json::encodeArray(['foo' => 'Foo', 'bar' => 'Bar']);

output(Json::decode($encode, true)['foo']);
foo

 

# DecodeObject ( ZN >= 2.0.0 )


Used to fetch the encrypted data in object form.

Parameters

String $ data The data to be resolved in custom format.
Int $ length = 512 Data length.
return Object

Use of

$encode = Json::encodeObject(['foo' => 'Foo', 'bar' => 'Bar']);

output(Json::decode($encode, true)->foo);
foo

 

# Check ( ZN> = 4.0.0 )


It is used to check if the encrypted data is json data.

Parameters

String $ data To be checked JSON data.
return Bool

Use of

$encode = Json::encode(['foo' => 'Foo', 'bar' => 'Bar']);

if( Json::check($encode) )
{
    # your codes
}
else
{
    # your codes
}

 

# Error / Errno ( ZN> = 2.0.0 )


Indicates whether there is an error in the Json operation.

Parameters

void
return Bool

Use of

echo Json::error();
echo Json::errno();