Steven Noble
Steven Noble

Reputation: 10425

Php's json_decode and firefox's javascript compatibility

it appears if you have something like

var my_var = {"foo" : "bar"};

in javascript (with firefox at least) and post it to a php server you will receive a string like

{foo:"bar",}

on the server side. But json_decode in php doesn't like the trailing ',' or the lack or quotes around 'foo'. Is there a nice way to clean up the received json string?

The json object is sent with the drupal module json services.

EDIT: This question can be closed. The badly formed json is due to badly written js in the drupal module

Upvotes: 2

Views: 1050

Answers (1)

John Millikin
John Millikin

Reputation: 200916

What code are you using to POST the data? Make sure you're using something like json2.js.

Upvotes: 2

Related Questions