Welcome Guest, Not a member yet? Register   Sign In
CI Client Parsing JSON
#2

(This post was last modified: 03-30-2015, 04:39 AM by RWCH.)

Can you tell what specific problem you have? Returning JSON is easy.

An example:

PHP Code:
 $tennisArray = array('Djokovic' => 1'Federer' => 2'Nadal' => 3'Murray' => 4);

 echo json_encode($tennisArray); //Take care you only echo JSON objects 

The code above will output the JSON formatted data like this:

Code:
{"Djokovic":1,"Federer":2,"Nadal":3,"Murray":4}

And if you need to encode an object, the following will probably do:

PHP Code:
 echo json_encode((array)$object); 

Good luck
Reply


Messages In This Thread
CI Client Parsing JSON - by cartalot - 03-29-2015, 05:55 PM
RE: CI Client Parsing JSON - by RWCH - 03-30-2015, 04:05 AM
RE: CI Client Parsing JSON - by cartalot - 03-30-2015, 12:15 PM
RE: CI Client Parsing JSON - by creanium - 03-30-2015, 12:48 PM
RE: CI Client Parsing JSON - by CroNiX - 03-30-2015, 12:51 PM
RE: CI Client Parsing JSON - by cartalot - 03-30-2015, 03:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB