1 Reply Latest reply on May 20, 2010 9:08 AM by Ansury

    JSON problem with array

    Handycam Level 1

      I have an array I am trying to json encode and send to a php file.  It would seem from the response from my php file that the second-level array members are recognized but empty.

       

      The array I am working with is:

      0,0,community-recipes,This is the post content lorem ipsum dolor sit amet,This is the post excerpt,Starter Salads,Serves four,/create-your-own-menu/backyard-bbq.aspx,some tag,another tag,make ahead,2205,1013,6229,11028,11030,11033,11039,11039
      

       

      There are 3 arrays inside this long one:

       

      some tag,another tag,make ahead
      2205,1013,6229
      11028,11030,11033,11039
      
      

       

      My PHP returns:

       

      sonSendData=[0,0,"community-recipes","This is the post content lorem ipsum dolor sit amet","This is the post excerpt","Starter Salads","Serves four","/create-your-own-menu/backyard-bbq.aspx",[{},{},{}],[{},{}],[{},{},{},{},{}],"11039"]
      <pre>
      Array
      (
          [0] => 0
          [1] => 0
          [2] => community-recipes
          [3] => This is the post content lorem ipsum dolor sit amet
          [4] => This is the post excerpt
          [5] => Starter Salads
          [6] => Serves four
          [7] => /create-your-own-menu/backyard-bbq.aspx
          [8] => Array
              (
                  [0] => stdClass Object
                      (
                      )
      
                  [1] => stdClass Object
                      (
                      )
      
                  [2] => stdClass Object
                      (
                      )
      
              )
      
          [9] => Array
              (
                  [0] => stdClass Object
                      (
                      )
      
                  [1] => stdClass Object
                      (
                      )
      
              )
      
          [10] => Array
              (
                  [0] => stdClass Object
                      (
                      )
      
                  [1] => stdClass Object
                      (
                      )
      
                  [2] => stdClass Object
                      (
                      )
      
                  [3] => stdClass Object
                      (
                      )
      
                  [4] => stdClass Object
                        (
                      )
      
              )
      
          [11] => 11039
      )
      </pre>
      

       

      As you can see, those arrays are present buy empty.  Here's the PHP:

       

      <?php
      print_r($_POST);
      while (list($k, $v) = each($_POST)) {
      
      echo $k . '=' . urldecode($v);
      
      } 
      
      
      $json = urldecode($_POST['jsonSendData']);
      
      $arr = json_decode($json);
      
      $txt = print_r($arr, true);
      
      ?>
      
      <pre>
      <?php echo $txt; ?>
      </pre>
      
      
      

        • 1. Re: JSON problem with array
          Ansury Level 3

          I guess this probably doesn't help, so forgive me if this is impossible for whatever reason, but is there a reason you're using a protocol that's inferior to AMF?  That seems like an awful lot of needless pain when you could be using any of :

          Zend AMF, AMFPHP, WebORB for PHP, or SabreAMF