1

The methods of the dynamic Google Graph API want Javascript object literals as their argument, but I only have the data as JSON. What do I do? Is there any way that I could convert my JSON to an object literal?

The format they want is here: http://code.google.com/intl/sv-SE/apis/chart/interactive/docs/reference.html#DataTable

I PHP, and also jQuery front end. I would appreciate front end or back end solutions. In the back end, I actually have the data in associative arrays so I can do anything with it there.

1 Answer 1

8

JSON is designed as a subset of Javascript object literal notation. Any* valid JSON code is already valid to interpret as a JavaScript literal.

* Technically, a few rare whitespace characters are treated differently, but this is relevant to almost nobody.

Sign up to request clarification or add additional context in comments.

1 Comment

It was a bug in my code to led me to ask this question, but I am happy I did as now I can feed the API data very easily with PHP's json_encode()! Thx.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.