Skip to content

Instantly share code, notes, and snippets.

@briandk
Last active August 29, 2015 14:21
Show Gist options
  • Save briandk/5e58e9ccb54727a6edc8 to your computer and use it in GitHub Desktop.
Save briandk/5e58e9ccb54727a6edc8 to your computer and use it in GitHub Desktop.
JSON export issue with Translations

How I understand the Translation field export

Here's an example of part of a value for Translations, in this case for the FCI:

"Translations": [{ "ar": ["Hisham A. Alhadlaq", 1 ] }

The general structure seems to be that Translations is an array of objects, where the scheme for each object is a key-value pair:

  • Key - A two-letter string representing the language
  • Value - An array of of length 2 consisting of:
    • a string of author names
    • an integer (either 1 or 0?)

I'll call such objects language objects.

The problem (as far as I can tell)

You're exporting an array of language objects, but the objects aren't comma separated

// an excerpted sample from the current export, 
// where there are no commas 
// separating the language objects

"Translations": [{ "ar": ["Hisham A. Alhadlaq", 1 ] } // there should be a comma here
{ "cs": ["J. BureÅ¡ová, D. Mandíková, Odborná revize překladu: L. Dvořák, V. Žák, E. Hejnová, J. Králík", 1 ] }]

What the export should look like

Apologies for the obscene whitespace--it's the default for JSONlint

// valid strict JSON requires
// comma-separated items in the language object array
{
    "Translations": [
        {
            "ar": [
                "Hisham A. Alhadlaq",
                1
            ]
        }, // This comma is key; it separates the language objects
        {
            "cs": [
                "J. BureÅ¡ová, D. Mandíková, Odborná revize překladu: L. Dvořák, V. Žák, E. Hejnová, J. Králík",
                1
            ]
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment