0

I have problems with JSON in playN 1.0.3 on HTML5. When I call JSON.parse(mystring) and try to decode the json document below I get this error:

com.google.gwt.core.client.JavaScriptException: (SyntaxError): JSON.parse: unexpected end of data

Note: JSON.parse() works in Java-Mode with this string perfectly. Moreover I validated the JSON-document using a JSON document validator (JSONLint).

Does anybody see the problem? Maybe the array or the objects in the array are the problem, right? Maybe it's too long? In reality, my array has 15 objects, which look similar to these three objects in the array below.

{
    "Array": [
        {
            "CorrectAnswer": "A",
            "AnswerA": "A",
            "AnswerD": "D",
            "Artist": "Artist",
            "AnswerB": "B",
            "Title": "Title",
            "AnswerC": "C"
        },
        {
            "CorrectAnswer": "A",
            "AnswerA": "A",
            "AnswerD": "D",
            "Artist": "Artist",
            "AnswerB": "B",
            "Title": "Title",
            "AnswerC": "C"
        },
        {
            "CorrectAnswer": "A",
            "AnswerA": "A",
            "AnswerD": "D",
            "Artist": "Artist",
            "AnswerB": "B",
            "Title": "Title",
            "AnswerC": "C"
        }
    ]
}
Dr. Rajesh Rolen
  • 14,029
  • 41
  • 106
  • 178
user1141785
  • 431
  • 7
  • 21
  • Are you sure this is the document returned by the server? Maybe a server side error is happening and a error page is returned instead? – RoToRa Jan 18 '12 at 13:20
  • 1
    This could be related to the [same-origin-policy](http://en.wikipedia.org/wiki/Same_origin_policy). Have you tried using another web-browser? I get the same problem with firefox, but the same code works with chrome. –  Jan 19 '12 at 15:24
  • Okay, my logger says, the document, which is returned is empty (and is not empty, when I use Java-Mode. I think Quan is right with the problems with the same-origin-policy - but the code does not work in chrome 16.0 (strange) If the app does not work in firefox, it is not really useful, since many people use it. So what can I do? Issue: PlayN is on Port 8080, Server is on port 8080, they can't communicate, due to the same-origin-policy. Solution: Server on 8080 writes a txt-File into the resources-Folder of PlayN. PlayN reads it out from txt-File. Do you hava any better solution? – user1141785 Jan 20 '12 at 14:56
  • I mean PlayN on 8888, Server on 8080 – user1141785 Jan 20 '12 at 15:02

1 Answers1

0

The problem is the same-orign-policy. Thanks to Quan. The solution is to deploy the war of the PlayN-html to the server (see Collaboration from PlayN client with server)

Community
  • 1
  • 1
user1141785
  • 431
  • 7
  • 21