2

If I run an "insert entity" request with a body like:

{
   "PartitionKey":[PartitionKey]",
   "RowKey":"[RowKey]",
   "Message":"[Message]"
}

What do I do if [Message] contains "strange" characters, e.g.

",\n   invalidinvalidinvalid

Is there a way to escape the values so that they are still parsed correctly by Azure? Will typical HTML escaping accomplish this?

Thanks!

bfops
  • 5,348
  • 5
  • 36
  • 48

1 Answers1

1

The data being posted must be a valid JSON document, so you need to escape special characters like backslashes \\ and double-quotes \". How you do this will depend on which language, most have a JSON library to handle this sort of thing.

Chris Fulstow
  • 41,170
  • 10
  • 86
  • 110
  • [this answer](http://stackoverflow.com/a/18104891/417803) gave me the rest of the details needed. C# doesn't have a good library for constructing JSON messages without creating a 1:1 correspondence with a data structure. – bfops Nov 12 '14 at 23:30
  • Maybe JSON.NET with an anonymous or dynamic object? – Chris Fulstow Nov 13 '14 at 01:08
  • oops sorry I meant "core C#". External libraries are a no-go for binary size reasons. – bfops Nov 13 '14 at 01:15
  • although actually JSON.NET is pretty tiny. I'll look into it, thanks! – bfops Nov 13 '14 at 01:16