Jump to content

FireFox don't load my json


Riddik
 Share

Recommended Posts

Hi!

 

In FireFox browser loader freezes at the moment loading my .json file with error message in console:

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data  phaser-arcade-physics.min.js:13

My .json file:

 

[{"bg":"day","spawn":[	{"monster_type":"0","time":"1"},	{"monster_type":"0","time":"4"},	{"monster_type":"1","time":"3"},	{"monster_type":"0","time":"3"},	{"monster_type":"1","time":"2"},					{"monster_type":"2","time":"3"},	{"monster_type":"2","time":"4"},	{"monster_type":"1","time":"1"}]},{"bg":"day","spawn":[	{"monster_type":"1","time":"1"},	{"monster_type":"0","time":"4"},	{"monster_type":"2","time":"3"},	{"monster_type":"1","time":"3"},	{"monster_type":"0","time":"2"},					{"monster_type":"2","time":"3"},	{"monster_type":"1","time":"4"},	{"monster_type":"1","time":"1"}]}]

What is my mistake?

 

Link to comment
Share on other sites

I am having this issue with only IPod 4 (That I have tested) my en.json language file just refuses to load on that device.  It has passed json validation. 

I will check the encoding, thanks lewster again :D

Link to comment
Share on other sites

I know very little about how encoding affects the parsing of files - I suspect the HTML or JavaScript (or both) have to match the encoding of the file you're trying to load in some browsers, but I can't confirm this. The JSON spec makes it plain that UTF-8 should be used - to quote the spec:

 

3. Encoding


JSON text SHALL be encoded in Unicode. The default encoding is UTF-8.

 

Also, your error seems to indicate that the problem may be in the very first character, which in Unicode files is where the BOM (byte order mark) is placed.

 

It's certainly caused a few seemingly bizarre issues before for me which is why I suggested it. Can anyone shed any light on this and clear it up? I realise it's not a Phaser related issue per se, but still...

Link to comment
Share on other sites

All JavaScript files were utf-8, except "phaser-arcade-physics.min.js" file - it is in ANSI. For test I changed this file encoding to UTF-8 and changed back my .JSON file to UTF-8. And again firefox can't load my json. 

Link to comment
Share on other sites

UTF-8 is the correct encoding format to use. What Firefox can't load is UTF-16 (and a variety of other formats), which is the default format generated by tools like Adobe Flash CC when exporting sprite sheets.

 

Also be aware of how your web server is handling the files and check it's not re-encoding them (some do!)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...