Problem while reading Json from a text file

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
mnaeem
Junior Coder
Posts: 30
Joined: Wed Mar 10, 2021 5:05 pm

Problem while reading Json from a text file

Post by mnaeem » Thu Nov 17, 2022 12:31 pm

Hello Experts,
I am facing a problem while reading Json. If you see the below line.

I am able to successfully read the JSON content from a file into this variable TempFileContent , however when I am going to the 2nd line to parse below mentioned json it gives error Invalid character JSON String

Code: Select all

ReadFile>%TempFolder%,TempFileContent
JSONParse>TempFileContent,$.isRunning,IsProcessRunning

Code: Select all

{
  "errorCode": "0",
  "isRunning": "False",
  "exeFileChecked": "C:\Program Files (x86)program\Program.exe"
}
Kindly advise how to resolve this issue.

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Problem while reading Json from a text file

Post by Marcus Tettmar » Thu Nov 17, 2022 12:58 pm

You're getting this error because that is not valid JSON.

If you fix the JSON it will work. Here's the correct version:

Code: Select all

{
  "errorCode": "0",
  "isRunning": "False",
  "exeFileChecked": "C:\\Program Files (x86)program\\Program.exe"
}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

mnaeem
Junior Coder
Posts: 30
Joined: Wed Mar 10, 2021 5:05 pm

Re: Problem while reading Json from a text file

Post by mnaeem » Thu Nov 17, 2022 8:03 pm

Thank you so much Marcus. It worked perfectly.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts