JASON error in redirects.json file

When I try to upload my redirects.json file I get the following error:
Could not parse JSON: Unexpected token : in JSON at position 3

Begining of file looks like this:

301:
/untitled-13: /best-3-dog-foods-for-shedding-3-will-shock-you
/untitled-16: /ingredient-by-any-other-name

Can you try renaming redirects.json to redirects.yaml? Also make sure the file contents look like this:

301:
  /untitled-13: /best-3-dog-foods-for-shedding-3-will-shock-you
  /untitled-16: /ingredient-by-any-other-name
2 Likes

Thank you that worked.

I’m having this exact same error, calling out position 3 which is the colon after 301. I’ve tried saving as .yaml and uploading but it gives the same error. I’ve also run the code through https://jsonlint.com/ and it dings that colon with the following message:

Invalid JSON!
Error: Parse error on line 1:
301: /benefits-sessio
—^
Expecting ‘EOF’, ‘}’, ‘,’, ‘]’, got ‘:’

What else should I try?

This code looks like YAML, but it doesn’t look quite right.

I’d make sure the formatting is correct: Ghost Themes - Dynamic URLs & Routing

Additionally, I know you said you saved the file as YAML, but please try again.

On Windows, depending on your settings, the extension might not be displayed. When you save, do save AS, and make sure to choose the ‘all files’ format, removing the .json extension. (I suspect you saved it as filename.yaml.json …)

1 Like