This is how I solved this:
function ujson_decode($json) {
return json_decode(removeTrailingCommas(utf8_encode($json)));
}
function removeTrailingCommas($json) {
$json=preg_replace('/,\s*([\]}])/m', '$1', $json);
return $json;
}
$var=ujson_decode(stripslashes($_POST["blah"]));
perhaps there is a better solution but this works well for me....
Yann
On Tue, Dec 15, 2009 at 9:59 PM, Rob <[email protected]> wrote:
> It's probably caused by non-UTF-8 data being passed to json_encode(). There
> is some information on Google about it. ;)
>
> Rob
>
>
> On Tue, Dec 15, 2009 at 2:11 PM, mmjaeger <[email protected]> wrote:
>
>> Well Fabio, it's somewhat related to my mootools request as I'm unable
>> to process anything in Mootools, isn't it - I just thought that there
>> might be somebody who had a similar issue.
>>
>> On Dec 15, 12:04 pm, Fábio M. Costa <[email protected]> wrote:
>> > Please users, lets avoid posting problem from other languages and
>> frameworks
>> > other than javascript and mootools.
>> >
>> > --
>> > Fábio Miranda Costa
>> > Solucione Sistemas
>> > Engenheiro de interfaces
>> >
>> >
>> >
>> > On Tue, Dec 15, 2009 at 5:56 PM, mmjaeger <[email protected]> wrote:
>> > > Hello
>> > > I've a working ajaxRequest script - well, it work most of the time -
>> > > however, sometimes it fails and creates the following entry in a
>> > > php.log file:
>> >
>> > > 15-Dec-2009 11:21:59] PHP Warning: json_encode() [<a
>> > > href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8
>> > > sequence in argument in /home/file.php on line 73
>> >
>> > > Did anybody else run into an issue like this - how did you solve the
>> > > issue and what's causing it?
>> >
>> > > the code that returns the json in php is like this: print json_encode
>> > > ($array);
>> >
>> > > Thank you in advance for your input
>>
>
>