Sunday, March 29, 2015

Deserialization in JSON

JSON being a data exchange and interchange format, this was designed for running in JavaScript on websites. Serialization of JSON can be done in many of modern web programming and developing languages like PHP, ASP.NET, PERL, Python etc. JSONpickle is a python library for serialization and deserialization of complex python objects to and from JSON. Similarly ASP.NET, PHP etc. has their own libraries and methods for deserialization of data/objects  in JSON.

Below is a basic example that is simple enough to explain about deserialization of JSON using PHP as a root language.

PHP Script (deserialization.php)



 <?PHP  
 $json='{"Andy":1,"Joe":2,"James":3,"Niraj":4,"Kumar":5,"Katrina":6}';  
 echo "<pre>";  
 var_dump(json_decode($json));  
 var_dump(json_decode($json,true));  
 echo "</pre>";  
 ?>

No comments:

Post a Comment