Can not able to store JSON as string in dgraph

I am trying to store the JSON structure as string in node attributes. But can not able to store it. Please find the error below:

{"err": "rpc error: code = Unknown desc = while lexing _:new_currency <currency_rates> \"{\"EUR\":0.885512,\"GBP\":0.751047}\" . at line 1 column 35: Invalid input: E at lexText"}

The json structure i am trying to store is:

{"EUR":0.885512,"GBP":0.751047}"

Can someone please help me.

Thanks,

Are you escaping quotes as such:

_:new_currency <currency_rates> "{\"EUR\":0.885512,\"GBP\":0.751047}" .

We store json in string fields so it definitely works. We use the protobuf API though, not RDF strings directly.

So, I have a struct, and I am marshalling that struct and storing that as string. FYI i am using golang.

Looks like the outer quotas should not be escaped, but they are, so probably it is a bug in your program. How do you build/escape the metation? Should be something like

fmt.Sprintf(`_:new_currency <currency_rates> "%s" .`, quoted_json)