Reading Json response from clipboard

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

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

Reading Json response from clipboard

Post by mnaeem » Tue Nov 22, 2022 7:45 pm

Hello Great Minds,
I am using PowerShell script and from PowerShell I am setting up a json content mentioned below in the clipboard, however when I try to fetch the content from the MS script it gives this

JsonContent

Code: Select all

{
  "errorCode": 0,
  "accountFileInfo": "D:\\Data\\automation\\clientAccount.csv"
}
MS Script to read the content from clipboard and parse the JSON

Code: Select all

Let>v_clipboardData=
GetClipBoard>v_clipboardData,0
JSONParse>%v_clipboardData%,$.errorCode,v_jsonErrorCode
I am getting 2 error prompts
  • Line 6 : not appropriate
  • Unexpected character in JSON data
Please advise how can parse the JSON content from the clipboard.

Thanks

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

Re: Reading Json response from clipboard

Post by Marcus Tettmar » Wed Nov 23, 2022 4:43 pm

Hi,

Remove the % characters around the clipboard variable in the JSONParse line. You can also remove Let and the format value.

Code: Select all

GetClipBoard>v_clipboardData
JSONParse>v_clipboardData,$.errorCode,v_jsonErrorCode
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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