www.webdeveloper.com
Results 1 to 3 of 3

Thread: Can't send properly formatted JSON from .json file

  1. #1
    Join Date
    Apr 2010
    Location
    Brooklyn NY
    Posts
    104

    Can't send properly formatted JSON from .json file

    PHP Code:
    $file_name $res['fileName'];
        
    $file file_get_contents($file_name);
        
        
    $obj json_decode($file,true);
        
        echo 
    $_GET['callback'] . '("' json_encode($obj) . '");'
    That's my script.

    this is the .json file

    HTML Code:
    {"topic":{"prefix":"www.mysocialbeacon.com/files/tutorial/","slides":[{"prefix":"general/","topic":"General","img":"1.png","title":"Welcome"]}}
    basically I'm trying to return it to a javascript file and it's wrapping quotes around the wrong part. Here's the beginning of the response


    "{"topic":{"prefix":"www.mysocialbeacon.com\/files

  2. #2
    Join Date
    Jan 2007
    Location
    Wisconsin
    Posts
    2,120
    Not really sure what you want here, but two questions come to mind ...

    1. Why are you decoding and re-encoding the JSON? (If the file is JSON anyway, why not just send it as-is?)

    2. Why are you wrapping the JSON object in quotes at all?
    Jon Wire

    thepointless.com | rounded corner generator

    I agree with Apple. Flash is just terrible.

    Use CODE tags!

  3. #3
    Join Date
    Apr 2010
    Location
    Brooklyn NY
    Posts
    104

    resolved

    Ok yea, i forgot that I was wrapping the callback in quotes. thx

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles