namespace \webfiori\json
class Json
Class Attributes Summary
Class Methods Summary
Class Attributes Details
- \
- /
- "
- \t
- \r
- \n
- \f
Class Methods Details
Parameters:
- string $key The value of the key. Note that the style of the key does not matter.
Parameters:
- array|string $initialData Initial data which is used to initialize the object. It can be a string which looks like JSON or it can be an associative array. If it is an associative array, then the keys will be acting as properties and the value of each key will be the value of the property.
- boolean $isFormatted If this attribute is set to true, the generated JSON will be indented and have new lines (readable). Note that the parameter will be ignored if the constant 'WF_VERBOSE' is defined and is set to true.
Parameters:
Parameters:
Parameters:
Parameters:
- array $arr An associative array. The keys will act as object keys in JSON and the values of the keys will be the values in JSON.
Adds a number to the JSON data. Note that if the given number is the constant INF or the constant NAN, The method will add them as a string. The 'INF' will be added as the string "Infinity" and the 'NAN' will be added as the string "Nan".
Parameters:
Adds an object to the JSON string. The object that will be added can implement the interface JsonI to make the generated JSON string customizable. Also, the object can be of type Json. If the given value is an object that does not implement the interface JsonI or it is not of type Json, The method will try to extract object information based on its "getXxxxx()" public methods. Assuming that the object has 2 public methods with names
getFirstProp()
and getSecondProp()
. In that case, the generated JSON will be on the formate {"FirstProp":"prop-1","SecondProp":""}.Parameters:
Parameters:
Parameters:
- string $jsonStr A string which looks like JSON object.
Parameters:
- string $string A value of one of JSON object properties.
Parameters:
- string $pathToJsonFile The full path to a file that contains JSON data.
Json
instance, the method will return an object of type Json
. If the method was unable to convert file data to an object of type Json
, it will return an array that contains error information. The array will have two indices, 'error-code' and 'error-message' Other than that, it will return null.- snake
- kebab
- camel
- none
Parameters:
- string $key The name of the key.
Parameters:
- string $keyName The name of the property.
Parameters:
- boolean $bool True to make the output formatted and false to make it not.
Parameters:
- string $style The style that will be used. It can be one of the following values:
- camel
- kebab
- snake
- none