I've used flash CS6 to export an animation to a spritesheet. This gives me 2 files: a png and a json file.
this is a simplified version of the json:
{"frames":
{
"movieclip 10000":
{
"frame": {"x":676,"y":0,"w":164,"h":280},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":164,"h":280},
"sourceSize": {"w":164,"h":280}
},
…
"movieclip 10004":
{
"frame": {"x":671,"y":280,"w":164,"h":280},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":164,"h":280},
"sourceSize": {"w":164,"h":280}
}
},
"meta": {
"app": "Adobe Flash CS6",
"version": "12.0.2.529",
"image": "boom1 8B4 def.png",
"format": "RGBA8888",
"size": {"w":1024,"h":1000},
"scale": "1"
}
Nothing special here. But the file is encoded in (according to textwrangler) UTF-16 Little Endian. This doesn't give any problems in Chrome, but when parsing the json in FF I get a "parsererror".
When I change the encoding of the file, it works without any problem in firefox.
So here is my question : (How) can I change the encoding using javascript?
this snippet is how I load my json:
$.ajax({
type: "POST",
url: this.json,
scriptCharset: "utf-8",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(json) {
that.jsonLoadHandler(json);
},
error: function (xhr, textStatus, errorThrown) {
that.errorHandler(xhr, textStatus);
}
});
Thank you for your time.
Instead of contentType: "application/json; charset=utf-8" use only contentType: "application/json;" this may resolve your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.