Tag Archives: json tutorials

json_encode ? Returns the JSON representation of a value

json_encode function will returns a string containing the JSON representation of a value.it supports only UTF-8 encoded See the Example here

Output: ——- {“v1″:1,”v2″:2,”v3″:3,”v4″:4,”v5”:5}

json_decode ? Decodes a JSON string

json_decode function takes json encoded straing and converted to php variable. this function works only for UTF-8 encoded string. for Example check the below code

object(stdClass)#1 (5) { [“v1”]=> int(1) [“v2”]=> int(2) [“v3”]=> int(3) [“v4”]=> int(4) [“v5”]=> int(5) } array(5) { [“v1”]=> int(1) [“v2”]=> int(2) [“v3”]=> int(3) [“v4”]=> int(4) [“v5”]=> int(5) }