1

I cannot seem to find any other hint of others having this issue, but when I run

Dim jsonstring As String = JsonConvert.SerializeObject(faxtosend)

My Json string has everything in double quotes, for example

"{""Faxto"":""12345678"",""From"":""87654321"",""Highquality"":false,""Documents"":{""Filename"":""test.pdf"",""FileContents"":""[base64 encoded file]""}}"

As you could imagine this is breaking the API I am trying to send the data to. I cannot see any reason for this to be happening. Does anyone have any idea what could be happening here. If I remove the additional quotes the JSON is valid, but I cannot figure out why they are being added in the first place.

mrtechguy
  • 35
  • 8
  • You can patch them using String.Replace, because the code looks right. – z3nth10n May 10 '18 at 00:55
  • That looks like something afterwards is escaping the string -- the double double quotes is how you escape quotes in a string. How are you displaying the JSON output? – Joe May 10 '18 at 00:58
  • Could you provide a desired json output example? I can't figure out what exactly your problme is; double quotes vs double double quotes. – Attacktive May 10 '18 at 01:08
  • The above output I got from watching the output of jsonstring. I am wanting to send the output to the GoFax API [found here](https://restful-api.gofax.com.au/swagger/ui/index#!/SendFaxesV1/SendFaxesV1_Send) – mrtechguy May 10 '18 at 02:59
  • We need to see a [mcve], but I will hazard a guess that you are double-serializing your JSON, e.g. as shown in [JSON.NET Parser *seems* to be double serializing my objects](https://stackoverflow.com/q/25559179/3744182). Or perhaps you're serializing your JSON then posting it using an API such as [`PostAsJsonAsync`](https://msdn.microsoft.com/en-us/library/hh944521(v=vs.118).aspx) which serializes it again. But without a full example I cannot say for sure. – dbc May 10 '18 at 03:24
  • 1
    I feel a little silly now. The issue wasn't the double quotes (while it is still a little weird) The actual issue is that documents is supposed to be an array (so should be surrounded by [ and ]) Thanks all for the help. – mrtechguy May 10 '18 at 04:55

0 Answers0