I exported an SQL table in a JSON file using PhpMyAdmin tools.
I got a file like this:
/**
Export to JSON plugin for PHPMyAdmin
@version 0.1
*/
// Database 'table_name'
// ...
[{"id": 7,"field1": "value1","field2": 2,"field3": "Lorem^M
ipsum^M
dolor^M
sit^M
amet","field4": "value4"}]
It's clear that the first lines (that are comments are not valid because JSON doesn't allow comments).
I know that ^M
is caused by the DOS/Windows line-ending characters.
Running jsonlint myexportedfile.json
after removing the comments I get this:
[Error: Parse error on line 1:
dolorld2": 2,"field3": "Lorem
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined']
Still, is this a valid JSON format? What character am I supposed to replace ^M
character? New line (\\n
), or?
I want to be able to do require("./myexportedfile")
in NodeJS and to get the data and then to make some changes.