Friday, November 9, 2018

How to parse JSON object from a Restlet in PHP

How to parse JSON object from a Restlet in PHP?

A RESTlet call returns a value as a JSON object. The sample code snippet below shows how to decode a JSON encoded string($json_object) and converts it into PHP variable

PHP Reference Guide:json_decode -

Example: json_decode()




$json_object = '{"a":1,"b":2,"c":3,"d":4,"e":5}';


$php_variable = json_decode($json_object,true);


foreach ($php_variable as $keys=>$values){


    echo $keys." : ".$values." ";






Above example will output:


a : 1 b : 2 c : 3 d : 4 e : 5



DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Netsuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.



Netsuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Netsuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.



Netsuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment