title: Replace "\" in string
body: <p>I am struggling how to handle a situation where JSON i am being sent appears to have unescaped characters in it.</p>
  
  <p>I have traced it to some barcodes having a backslash at the beginning.</p>
  
  <blockquote>
    <p>\"barcode\":\"\0030172391286\"</p>
  </blockquote>
  
  <p>JsonSerializer.Deserialize throws an error converting it to an object.</p>
  
  <p>My idea is to use the .Replace function to remove the "\" in front of the barcode.</p>
  
  <p>My attempt at getting the .Replace function is:</p>
  
  <pre><code>data.JSON = data.JSON.Replace(@"\""barcode\"":\""\", @"\""barcode\"":\""");
  </code></pre>
  
  <p>but it's not working.</p>
  
  <p>Can anyone suggest how to get the replace function working or suggest a better alternative?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It appears that I am incorrect. It might not be the "\" that is the problem.</p>
  
  <p>It might be the "\0" which represents a NUL</p>
  
  <p>So. I have tried:</p>
  
  <pre><code>JsonSerializerOptions options = new JsonSerializerOptions
  {
       IgnoreNullValues = true,
  };
  LM_BegInventory LM_Inventory = JsonSerializer.Deserialize&lt;LM_BegInventory&gt;(data.JSON, options);
  </code></pre>
  
  <p>but it still fails with the error:</p>
  
  <blockquote>
    <p>System.Text.Json.JsonException: '0x00' is invalid within a JSON
    string. The string should be correctly escaped. Path: $['transaction
    detail'][5850].barcode | LineNumber: 0 | BytePositionInLine: 1457061.
    ---> System.Text.Json.JsonReaderException: '0x00' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 0 |
    BytePositionInLine: 1457061.</p>
  </blockquote>