Weird JSON parsing error using require() in node.js

javascript, node.js

Solution

It sounds like you made a `.js` file, not a `.json` file. Therefore, it's being parsed as Javascript, not JSON.

Problem

I have the following JSON: ``` { "request" : { "language" : "en", "title" : "placeholder", "year" : "2014" } } ``` which I'm trying to parse using the following code: ``` var json = require('../filename); ``` Oddly, I receive the SyntaxError ``` /home/username/code/filename:2 "request" : { ^ SyntaxError: Unexpected token : (...) ``` The JSON is perfectly valid according to JSONLint. Am I missing something very obvious?

Original source

Related problems