-3

I saved the code you(emeditor) shared for JsonToCsv.jsee and followed your instruction"then select this file from Select... in the Macros menu. Finally, open your data file, and select Run in the Macros menu " but I'm getting this error screenshot

Here's one of the lines in the Json file. {"_id":{"$oid":"504e5fe7313ea25b9b00003f"},"date_joined":{"$date":"2011-12-16T23:17:33.000Z"},"email":"sample@abc.net","first_name":"","group":"virtela","is_active":true,"is_staff":false,"is_superuser":false,"last_login":{"$date":"2012-11-29T07:40:08.961Z"},"last_name":"","password":"sample","url_logging_enabled":false,"username":"sample@abc.com"}

The desired outcome could would be converting this in CSV format. i.e. screenshot

please advise.

Thank you.

maxproflt
  • 3
  • 2
  • Does this answer your question? [How can I convert JSON to CSV?](https://stackoverflow.com/questions/1871524/how-can-i-convert-json-to-csv) – Eduardo Páez Rubio May 15 '22 at 09:56
  • I think you are referring to a macro in [this answer](https://stackoverflow.com/questions/63220312/how-to-convert-json-file-to-excel), but not all JSON files can convert to CSV using this macro. Please write a simplified sample of your JSON files to explain your question. – Yutaka May 17 '22 at 23:47
  • Hi, Here's one of the lines in the Json file. please advise how to convert this to CSV format. Thank you. {"_id":{"$oid":"504e5fe7313ea25b9b00003f"},"date_joined":{"$date":"2011-12-16T23:17:33.000Z"},"email":"sample@abc.net","first_name":"","group":"virtela","is_active":true,"is_staff":false,"is_superuser":false,"last_login":{"$date":"2012-11-29T07:40:08.961Z"},"last_name":"","password":"sample","url_logging_enabled":false,"username":"sample@abc.com"} – maxproflt May 18 '22 at 05:00
  • Please also write an output file that you expect to get when you convert the input file. Please include all these file samples within your question with an appropriate format. Please also show your effort (what you have tried so far). – Yutaka May 18 '22 at 15:38
  • Hi Yutaka, I edited my origial post. Sorry I'm not too familiar with using stackoverflow. Please forgive me if my formatting is not proper... – maxproflt May 18 '22 at 20:39

1 Answers1

0

There was one issue in the macro at this answer, and I've already updated this answer. Please copy the macro again. (the 3rd line was updated to include toString()). I've tested your sample JSON file and I was able to use this macro without any issues. The output became:

$oid,$date,email,first_name,group,is_active,is_staff,is_superuser,$date,last_name,password,url_logging_enabled,username
504e5fe7313ea25b9b00003f,2011-12-16T23:17:33.000Z,sample@abc.net,,virtela,true,false,false,2012-11-29T07:40:08.961Z,,sample,false,sample@abc.com

However, the error message you saw (Syntax error at Line 12) in your screenshot was due to a different reason. You were probably using a very old version of EmEditor. Older versions of EmEditor did not support JSON. Please update EmEditor and make sure you are using the latest version of EmEditor.

Yutaka
  • 1,761
  • 2
  • 5
  • 9
  • If this answers your questions, please click the left checkmark to show you accept this answer. Please do the same for the [other question](https://stackoverflow.com/questions/71965887/embedded-character-with-reversed-background) you asked before. – Yutaka May 19 '22 at 15:42
  • Hi @Yutaka, I noticed that the error occurs with the macro when there's more than 1 line in json file. I tried one line and it converted but when I duplicated the same line, the error was generated. I'm using the latest version. What's the remedy here? thanks – maxproflt Aug 01 '22 at 01:03