Json Help

They have: 426 posts

Joined: Feb 2005

I am having some problems with JSON.

So i have a URL which is outputting JSON code. I need to parse this into a usable object.

So far i have done this:

var jsonURL = "http://www.thejasoncode.com/JSONGenerator?cid=20000&parameter1=something&pparameter2=something&callback=callbackresults

var myObject = eval('(' + jsonURL + ')');
div.innerHTML = typeof(myObject);

return div;

I am trying to verify that it is returning an object by using typeof(). Firefox error console is telling me that

Error: missing ) in parenthetical
Source File: source file
Line: 21, Column: 5
Source Code:
here it shows the URL and an arrow pointing to ":" after http.

any ideas of help appreciated

They have: 121 posts

Joined: Dec 2008

Could just be the forum, or the cut and paste job, but I don't see a close quote, or semi colon on the first JS line there, where you define the jsonURL. I'm no JS guru, but open ended quotes can often create misleading errors...

Cheers,
Shaggy

They have: 426 posts

Joined: Feb 2005

I have still not actually solved this problem as yet. Please someone tell me that this damn json is worth all the headache.

I cannot get the JSON callback function to work unless i explicitly write the include and the callback function directly on the page.

For example.

I want to use all the data from the JSON callback function to create elements to put on the page. This means i want to just include a file that does all this.

If i include a javascript file that has my callback function and the included external URL JSON object it just does not work.

expample.....

<html>
<head></head>
<body>
<script src="myjsonstuff.js" type="text/javascript"></script>
</body>
</html>

But when i explicitly write the damn thing on the page it does work.

example....

<html>
<head></head>
<body>
<script>
function jsonresults(obj){
  jsonvariable = obj.somejson.so[0].ti;
</script>
<script src="http;//www.json.php?parm=5&param=4&callback=jsonresults" type="text/javascript"></script>
</body>
</html>

can someone please advise me how i can get this working. It just seems to ridiculous too be true.

They have: 121 posts

Joined: Dec 2008

You've confirmed that the file 'myjsonstuff.js' is web accessible in the context/path you've given in the include?

Cheers,
Shaggy

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

http;//www.json.php?parm=5&param=4&callb...
You're using a semicolon instead of a colon right after HTTP

You can call me Eagle Eye...

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

And .php is not a valid TLD.

http://www.json.com perhaps?

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.