User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

json_implode [2017/07/06 04:08] (current)
caf created
Line 1: Line 1:
 +This function serialises an assign variable structure into a [[http://​​|JSON]] string.
 +All sub-structures are stored as JSON sub-objects,​ and all assign values are stored as JSON string values. ​ If a part of the structure is both a sub-structure and has an assign value, the sub-structure is stored. Only global assign structures can be serialised.
 +An assign variable structure can be losslessly round-tripped through [[json_implode]] and [[json_explode]],​ so this function is a good way for a script to serialise state to a file and reconstruct it later.
 +If the function fails, an empty string is returned.
 +|<<​string>>​|The JSON serialised form of the structure <<​var>>​.|
 +|<<​empty>>​|The function failed (probably because <<​var>>​ is not a structure).|
 +  @ foo[client] = [EPIC]
 +  @ foo[details][description] = [EPIC rocks!]
 +  @ foo[details][protocol] = [IRC]
 +  @ foo[details][port] = 6667
 +  ​
 +  echo $json_implode(foo)
 +  ​
 +======See Also:======
 +[[json_error]],​ [[json_explode]]
json_implode.txt ยท Last modified: 2017/07/06 04:08 by caf