Importing EXAMPLE json file from documentation doesn't work - Ghost PRO

I’m having major problems trying to import content from my local ghost installation. Nothing has been working, so I figured I’d go back to basics and try the example in the documentation. The code is from here: https://ghost.org/docs/api/v2/migration/

This is the error I get trying to import both locally and on live Ghost Pro installation.

Import failed

check that the import file is valid JSON.: Unexpected token / in JSON at position 23

{
    "meta":{
        // epoch time in milliseconds
        "exported_on":  1388805572000,
        "version":      "2.14.0"
    },
    "data":{
        "posts": [
            {
                "id": 1,
                "title":         "my blog post title",
                "slug":          "my-blog-post-title", // Optional, will be generated by Ghost if missing
                // mobiledoc is used to represent your content
                "mobiledoc":     "{\"version\":\"0.3.1\",\"atoms\":[],\"cards\":[],\"markups\":[],\"sections\":[[1,\"p\",[[0,[],0,\"You're live, nice!\"]]]]}",
                "feature_image": null,
                "featured":      0, // boolean indicating featured status
                "page":          0, // boolean indicating if this is a page or post
                "status":        "published", // or draft
                "published_at":  1283780649000, // epoch time in milliseconds
                "published_by":  1, // the first user created has an id of 1
                "meta_title":    null,
                "meta_description":null,
                "author_id":     1, // the first user created has an id of 1
                "created_at":    1283780649000, // epoch time in milliseconds
                "created_by":    1, // the first user created has an id of 1
                "updated_at":    1286958624000, // epoch time in milliseconds
                "updated_by":    1 // the first user created has an id of 1
            }
        ],
        "tags": [
            {
                "id":           5,
                "name":         "Colorado Ho!",
                "slug":         "colorado-ho", // Optional, will be generated by Ghost if missing
                "description":  ""
            }
        ],
        "posts_tags": [
            {"tag_id": 5, "post_id": 1},
        ],
        "users": [
            {
                "id":           3,
                "name":         "Jo Bloggs",
                "slug":         "jo-blogs", // Optional, will be generated by Ghost if missing
                "email":        "jo@example.com",
                "profile_image": null,
                "cover_image":   null,
                "bio":           null,
                "website":       null,
                "location":      null,
                "accessibility": null,
                "meta_title":    null,
                "meta_description": null,
                "created_at":    1283780649000, // epoch time in millis
                "created_by":    1,
                "updated_at":    1286958624000, // epoch time in millis
                "updated_by":    1
            }
        ],
        // Provide this if you want different roles to the default "Author" role
        "roles_users": [
            {
                "user_id": 2,
                "role_id": ObjectId // This must reference the id from your database
            }
        ]
    }
}

Looks like it was to do with encoding. Once I minified it worked.
That was sending me a big crazy. Hope this help someone in the future :slight_smile:

@andrewmc JSON does not support comments (the lines or content starting with //). What you have copied is not intended to be imported but an explanation of what the different bits of data in an import file represent :wink:

I expect minifying it removed the unrecognised syntax which then produced a valid JSON file.

1 Like