Unable to parse Datas as JSON

Discussions of the development process of the game.
Post Reply
User avatar
Meirerion
Posts: 209
Joined: Sun Jun 24, 2012 10:49 am
android_version: 2.3 - Gingerbread
Location: Under a keg.

Unable to parse Datas as JSON

Post by Meirerion » Wed Apr 10, 2013 3:10 pm

I recently wrote some dialogues for the "parallel dimensions" (topic in ideas'n'suggestions). I copied it (I always care not to make any mistakes (not copying [ ] { }) and today I tried to import it but... "unable to parse Datas as JSOn".
I spent half an hour trying to find the mistake but I couldn't find it.

If anyone sees it, it would be great. :?

Code: Select all

[
  {
    "id": "irhain_start",
    "replies": [
      {
        "nextPhraseID": "ihrain_introduction",
        "text": "Hello."
      },
      {
        "requires": {
          "progress": "dimension:1"
        },
        "text": "GREETINGS2"
      },
      {
        "requires": {
          "progress": "dimension:2"
        },
        "text": "GREETINGS3"
      }
    ],
    "message": "Hello young man."
  },
  {
    "id": "ihrain_introduction",
    "replies": [
      {
        "text": "Used?",
        "nextPhraseID": "ihrain_introductionpast"
      },
      {
        "text": "And what is your business here?",
        "nextPhraseID": "ihrain_startquest"
      }
    ],
    "message": "Let me introduce myself. My name is Irhain and I come
from the distant city of Sullengard.\nPeople in my city used to call
me the Elementalist."
  },
  {
    "id": "ihrain_introductionpast",
    "replies": [
      {
        "text": "N",
        "nextPhraseID": "ihrain_startquest"
      }
    ],
    "message": "Well.. I had some problems with the city
watch...\nLet's forget about that. I'm still an elementalist even if
they call me \"Madman\"."
  },
  {
    "id": "ihrain_startquest",
    "replies": [
      {
        "text": "Lot of money? You've my curiosity.",
        "nextPhraseID": "ihrain_quest"
      },
      {
        "text": "People around me always told me not to trust wizards.",
        "nextPhraseID": "ihrain_trust"
      },
      {
        "text": "Working with a wizard? No thank you.",
        "nextPhraseID": "ihrain_comeback"
      }
    ],
    "message": "I have a proposition for you, something new and
wonderful. And... A lot of money could be made if you listen closely."
  },
  {
    "id": "ihrain_comeback",
    "message": "Look for me if you ever change your thought."
  },
  {
    "id": "ihrain_quest",
    "replies": [
      {
        "text": "N",
        "nextPhraseID": "ihrain_quest_1"
      }
    ],
    "message": "I was travelling from Stoutford to Nor City, dodging
bees and wolfs, when I saw a strange light. It looked like a reddish
moon fell in the forest but it still shone."
  },
  {
    "id": "ihrain_quest_1",
    "replies": [
      {
        "text": "N",
        "nextPhraseID": "ihrain_quest_2"
      }
    ],
    "message": "I approached slowly wondering what mysterious ritual
took place in this dark forest."
  },
  {
    "id": "ihrain_quest_2",
    "replies": [
      {
        "text": "A portal? Interesting. Did you enter?",
        "nextPhraseID": "ihrain_questcoward"
      },
      {
        "text": "A portal? I don't trust you. You just want me to go
in the forest and wait for your friends to rob me. Goodbye.",
        "nextPhraseID": "ihrain_comeback"
      }
    ],
    "message": "I hid in a tree at the edge of the forest and looked
in the direction of the pale light. It was no moon nor moon rocks,  it
was a portal!"
  },
  {
    "id": "ihrain_questcoward",
    "replies": [
      {
        "text": "N"
      }
    ],
    "message": "Well, not really. I'm not that young and I think I
should leave those adventures to the young generation."
  },
  {
    "id": "ihrain_trust",
    "replies": [
      {
        "text": "I'm listening.",
        "nextPhraseID": "ihrain_quest"
      },
      {
        "text": "You're wasting my time wizard, look for another fool.",
        "nextPhraseID": "ihrain_comeback"
      }
    ],
    "message": "And I tell you not to trust them, now are you
listening or are you wasting my time?"
  }
]

EDIT:

Oh and btw, if you see a mistake, report it ;)
~May Elythara's wisdom light your path

Stompp
Posts: 65
Joined: Tue Feb 05, 2013 11:08 pm
android_version: 4.0

Re: Unable to parse Datas as JSON

Post by Stompp » Wed Apr 10, 2013 3:24 pm

Stupid question, do you have to escape the single quotes?

"Well.. I had some problems with the city
watch...\nLet's forget about that. I'm still an elementalist even if
they call me \"Madman\"."
Lvl: 30, XP: 478811, Gold: gone, RoLS: 1, RoL: 0
HP: 83, AC: 246%, AD: 20-24, AP: 3/12, ECC: 23%, CM: 3, BC: 50%, DR: 0

oskarwiksten
Captain Awesome
Posts: 368
Joined: Sat Jan 29, 2011 8:51 am
android_version: 2.3 - Gingerbread
Location: Stockholm, Sweden

Re: Unable to parse Datas as JSON

Post by oskarwiksten » Sat Apr 13, 2013 11:05 am

Hi Meirerion,

seems like an interesting questline. Looking forward to reading more of it!

About the error when loading this into the content editor, it seems like something has split all your long conversation lines into several lines.
For example:

Code: Select all

"message": "And I tell you not to trust them, now are you
listening or are you wasting my time?"
The fact that there's a new line inside the double quotes is what's making the content editor barf when importing it. The correct way would be to have it as just one long line:

Code: Select all

"message": "And I tell you not to trust them, now are you listening or are you wasting my time?"
You are of course welcome to break phrases over several lines when entering the phrase text itself into the editor. If you really want a new line in the phrase message, it would be encoded as "\n" in the json export, but that should all be handled automatically by the content editor.

Hope that clears things up!
/Oskar

User avatar
Meirerion
Posts: 209
Joined: Sun Jun 24, 2012 10:49 am
android_version: 2.3 - Gingerbread
Location: Under a keg.

Re: Unable to parse Datas as JSON

Post by Meirerion » Sun Apr 14, 2013 9:37 am

oskarwiksten wrote:Hi Meirerion,

seems like an interesting questline. Looking forward to reading more of it!

About the error when loading this into the content editor, it seems like something has split all your long conversation lines into several lines.
For example:

Code: Select all

"message": "And I tell you not to trust them, now are you
listening or are you wasting my time?"
The fact that there's a new line inside the double quotes is what's making the content editor barf when importing it. The correct way would be to have it as just one long line:

Code: Select all

"message": "And I tell you not to trust them, now are you listening or are you wasting my time?"
You are of course welcome to break phrases over several lines when entering the phrase text itself into the editor. If you really want a new line in the phrase message, it would be encoded as "\n" in the json export, but that should all be handled automatically by the content editor.

Hope that clears things up!

Thank you very much Oskar :), I'll check this afternoon if it works now.
~May Elythara's wisdom light your path

Post Reply