escape some characters while using JSONParse

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
bbrink
Pro Scripter
Posts: 70
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

escape some characters while using JSONParse

Post by bbrink » Tue May 10, 2022 6:57 pm

Hello All,

I am trying to get the "last" value from the "1INCH\/USDT" section. I am using block notation, as I understand it handles the special characters better. The code as written below fails to return a result. If I test by replacing "1INCH\/USDT" with "hello" it runs fine. I am guessing the slashes are giving me trouble. Can someone please help me code around that?

Code: Select all

/*
MyJSON:
{
	"data": {
		"1EARTH\/USDT": {
			"currencyPair": "1EARTH\/USDT",
			"last": "0.012645",
			"lowestAsk": "0.012645",
			"highestBid": "0.012606",
			"24hrLow": "0.01068"
		},
	  "1INCH\/USDT": {
      "currencyPair": "1INCH\/USDT",
      "last": "1.106",
      "lowestAsk": "1.108",
      "highestBid": "1.106",
      "24hrLow": "0.998"
    },
    "aUSD\/USDT": {
      "currencyPair": "aUSD\/USDT",
			"last": "0.9981",
			"lowestAsk": "0.999",
			"highestBid": "0.9981",
			"percentChange": "-0.0019",
			"24hrLow": "0.9948"
		}
	}
}
*/

LabelToVar>MyJSON,sJSON
Let>MyPair=1INCH\/USDT

JSONParse>sJSON,$['data']['%MyPair%']['last'],result
MessageModal>Result_1

bbrink
Pro Scripter
Posts: 70
Joined: Thu Dec 31, 2009 2:36 am
Location: Minnesota
Contact:

Re: escape some characters while using JSONParse

Post by bbrink » Thu May 12, 2022 11:10 am

Hi,

Not sure if it is the only answer, but I solved this by running the entire file through a loop, and monitoring for currencyPair": "1INCH\/USDT". This kept the project moving and was a suitable answer but it did not help my understanding of JSONPARSE. I hope this helps others,

Bob

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