How to create a json for this structure

Discussion in 'PHP' started by Freewebspace, Jun 26, 2010.

  1. #1
    How to create json code for this?


    My Php code is

    <?php
    $content="asdasd";
    $ent1="tag:google.com,2010:buzz-group:1001062849:13";
    $object=array(object=>array(content=>$content));
    $entries=array(id=>$ent1);
    $visibility1=array($entries);
    
    $visibility2=array(visibility=>(array(entries=>$visibility1)));
    
    $a1=json_encode((array(data=>
    		(object=>array(content=>$content)),
    		(visibility=>(entries=>$entries)),
    		)
    		)
    		);
    PHP:

    What is wrong with my code?
     
    Freewebspace, Jun 26, 2010 IP
  2. webria

    webria Peon

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you need to prepare array correctly so that json_encode will convert the array to a proper json format as needed. Firebug helps on this.
     
    webria, Jul 6, 2010 IP