Escaping Quotes in a Variable

Hey all,

I’m new to eggPlant and I’m doing an evaluation with a trial key.

How do I include the " character in a string variable?

I’ve tried a few things, but the quotes always vanish, i.e…

put “this is a ““quoted”” word” into someVariable
log someVariable

I’m actually trying to build a JSON request to POST to an API, but I’m just struggling with the quotes.


put <<this is a "quoted" word>> into somevar


put "this is a" && quote & "quoted" & quote && "word" into somevar


Since you’re specifically working with JSON there are a couple of other things you might want to be aware of. First of all you may want to look at the JSONFormat() and JSONValue() functions which will convert any SenseTalk values (strings, lists, property lists, etc.) to or from JSON format.

Also, the JSON format is highly compatible with SenseTalk, so if you happen to have a data structure in JSON format you can copy and paste it directly into a script and it should work. The only exception is strings containing escape codes like
– SenseTalk treats quoted strings as literal values, so if your JSON data uses escape codes you’ll need to use the JSONValue() function to correctly convert those into SenseTalk data.

Here’s an example, with JSON data copied and pasted directly from the Wikipedia page on JSON:

set person to {
	"firstName": "John",
	"lastName": "Smith",
	"age": 25,
	"address": {
		"streetAddress": "21 2nd Street",
		"city": "New York",
		"state": "NY",
		"postalCode": 10021
	"phoneNumbers": [
			"type": "home",
			"number": "212 555-1234"
			"type": "fax",
			"number": "646 555-4567"

put person