Xamarin & Golang - { []} invalid character '\x00' looking for beginning of object key string
<p>I'm comming today because I'm stuck and it doesn't seems logic for me.</p>

<p>I have my server (<strong>Go</strong>) and my smartphone app (<strong>Xamarin C#</strong>).</p>

<p>For the Xamarin side, I'm using this package -> <a href="https://github.com/rdavisau/sockets-for-pcl" rel="nofollow">Sockets Plugin for Xamarin and Windows (PCL)</a></p>

<p>For the Go side, I'm using <a href="https://golang.org/pkg/encoding/json/" rel="nofollow">encoding/json</a></p>

<p>Everything in the Xamarin part is working fine. But in the Go side, it doesn't.. I'm using the following code to handle the messages from each <strong>net.Conn</strong>.</p>

<pre><code>type DialMessageContainer struct {
    Type string `json:"Type"`
    Content json.RawMessage `json:"Content"`
}

func (dialTCP *DialTCP) serve_conn(conn net.Conn) {

    fmt.Println("Handle new connection.")
    dec := json.NewDecoder(conn)
    var message m.DialMessageContainer

    //Use one of the following
    printContent(conn)                                                                                                                                                                                 
    // --
    err := dec.Decode(&amp;message)
    fmt.Println(message, err)
    //End

    conn.Close()
}

func printContent(conn net.Conn) {
    var buf bytes.Buffer
    io.Copy(&amp;buf, conn)
    fmt.Println(buf.String())
}
</code></pre>

<p>So, the type is here to let it know which type of json it is.  From this type string, it then unmarshal a json from the json.RawmMessage Content to the good object. I know it works, however when I try to recreate my object from the following json, I get  this error:</p>

<p><strong>(printContent no commented, then Decode has nothing to read, it's for the debug trace test)</strong></p>

<pre><code>....
Handle new connection.
{
  "Type": "Authentication",
  "Content": {
    "UUID": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Im1heGltZS1ndWl0dGV0QG91dGxvb2suY29tIiwiZXhwIjoxNDYyNjM4MTkzfQ.DEGJcDYl9Iq4nayo37Rq9ZsK8mrU-V8gU5I8JLO8oLg"
  }
}
{ []} EOF
</code></pre>

<p>So, <strong>when I hide the printContent(conn)</strong>, the dec.Decode gives this:</p>

<pre><code>....
Handle new connection.
{ []} invalid character '\x00' looking for beginning of object key string
</code></pre>

<p>The thing that I ask to myself is : "Does \x00 means the NULL CHAR of the ascii table?". If this error comes because of this char, so where does it is? Moreover, if it's this char, maybe it is just present to mark the end point of the string (use of '\0' in C to mark the end of a char*/char[]).</p>

<p>But, maybe I'm totaly wrong.. Honestly I'm stuck and I don't understand.. Aynway, <a href="http://jsonlint.com/" rel="nofollow">JSONLint</a> says it's a valid JSON so it can only be something about the reading I think</p>

<p>If anyone can help, thank !</p>