Jump to content

JSON Export Template


sentry0

Recommended Posts

I'm attempting to build a JSON export template and am having some success so far.  I've hit a bit of a snag though with characteristics not exporting properly...see the below snippet.

 

<!--TEMPLATE_NAME-->6E JSON Export<!--/TEMPLATE_NAME-->
<!--TEMPLATE_DESCRIPTION-->
    <p>A JSON template for the Hero System 6th Edition by sentry0</p>
    <p>
        Version 1.0.0 (2018-02-17)
      <!--FILE_EXTENSION-->json<!--/FILE_EXTENSION-->
    </p>
<!--/TEMPLATE_DESCRIPTION-->
{
    name: '<!--CHARACTER_NAME-->',
    characteristics: {
        strength: {
            total: '<!--STR--><!--STR_TOTAL--><!/--STR-->',
            cost: '<!--STR--><!--STR_COST--><!/--STR-->',
            roll: '<!--STR--><!--STR_ROLL--><!/--STR-->',
            notes: '<!--STR--><!--STR_NOTES--><!/--STR-->'
        }
    },
    movement: {
        running: '<!--RUNNING--><!--RUNNING_TOTAL-->[<!--IF_RUNNING--><!--RUNNING_TOTAL_NONCOMBAT--><!--/IF_RUNNING--> NC]<!--/RUNNING-->'
    }
}

 

The "name" and "running" properties populate correctly but I can't seem to get any of the strength properties to work.

 

Here's what HD is outputting for me:

 

{
	name: 'Edward Lightbinder',
	characteristics: {
		strength: {
			total: '<!--STR--><!--STR_TOTAL--><!/--STR-->',
			cost: '<!--STR--><!--STR_COST--><!/--STR-->',
			roll: '<!--STR--><!--STR_ROLL--><!/--STR-->',
			notes: '<!--STR--><!--STR_NOTES--><!/--STR-->'
		}
	},
	movement: {
		running: '6"[12" NC]'
	}
}

 

Link to comment
Share on other sites

My export template is sort of working, it's producing invalid JSON because some fields contain a single quote which happens to be what I'm using to quote my values.  I could switch to double quotes but it doesn't address the root issue which is if a player uses a single (or double quote) they will produce broken JSON.

 

Is there anyway for my to get like an XML dump from HD that I could use for further parsing?

Link to comment
Share on other sites

What I was trying to say is if you have some magical way to get the data out of HD and into a machine readable format I would take it.  If nothing like that exists then I'll just keep moving down the TSV path

 

The XML format would have the same issue as JSON, it would actually probably be worse because of the amount of special characters you would have to watch out for.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

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