gval icon indicating copy to clipboard operation
gval copied to clipboard

how to visit json node whose key with special characters,like $

Open 865389042 opened this issue 1 year ago • 0 comments

{
    "properties": {
       "$id": 1
    }
}
func Test2(t *testing.T) {
	parameters := make(map[string]interface{})
	jsonStr := `{"properties": {"$id": "123"}}`
	err := json.Unmarshal([]byte(jsonStr), &parameters)
	assert.Nil(t, err)
	expr, err := gval.Full().NewEvaluable("{\"id\":properties.`$id`}")
	assert.Nil(t, err) // parsing error: {"id":properties.`$id`}	:1:18 - 1:23 unexpected RawString while scanning field expected Ident
	result, err := expr(context.Background(), parameters)
	assert.Nil(t, err)
	_ = result
}

865389042 avatar Sep 15 '23 03:09 865389042