0

I am going to unit test a JSON file. One of the keys is "%changed". However, using JSONPath to test it, gives me an error. How can I successfully test it?

.andExpect(jsonPath("$.%Changed").isString())
   {
        "Open": "3,659.87",
        "Nominal": "3,722.79",
        "Change": "+73.54",
        "%Changed": "+2.02%",
        "Status": "1"
    }
wp78de
  • 18,207
  • 7
  • 43
  • 71
Lucy
  • 43
  • 7

1 Answers1

0

I'm not sure what framework or language you're using, but % can't be in a dot-property callout like that. You need to use the quoted index format:

$["%Changed"]

or

$['%Changed']
gregsdennis
  • 7,218
  • 3
  • 38
  • 71