title: Thrift - converting from simple JSON
body: <p>I created the following Thrift Object:</p>
  
  <pre><code>struct Student{
          1: string id;
          2: string firstName;
          3: string lastName
  }
  </code></pre>
  
  <p>Now I would like to read this object from JSON. According to this <a href="http://trevorgattis.blogspot.co.il/2011/12/apache-thrift-converting-from-simple.html" rel="noreferrer">post</a> this is possible</p>
  
  <p>So I wrote the following code:</p>
  
  <pre><code>String json = "{\"id\":\"aaa\",\"firstName\":\"Danny\",\"lastName\":\"Lesnik\"}";
      StudentThriftObject s = new StudentThriftObject();
      byte[] jsonAsByte = json.getBytes("UTF-8");
      TMemoryBuffer memBuffer = new TMemoryBuffer(jsonAsByte.length);
      memBuffer.write(jsonAsByte);
  
      TProtocol proto = new TJSONProtocol(memBuffer);
      s.read(proto);
  </code></pre>
  
  <p>What I'm getting is the following exception:</p>
  
  <pre><code>Exception in thread "main" org.apache.thrift.protocol.TProtocolException: Unexpected character:i
      at org.apache.thrift.protocol.TJSONProtocol.readJSONSyntaxChar(TJSONProtocol.java:322)
      at org.apache.thrift.protocol.TJSONProtocol.readJSONInteger(TJSONProtocol.java:698)
      at org.apache.thrift.protocol.TJSONProtocol.readFieldBegin(TJSONProtocol.java:837)
      at com.vanilla.thrift.example.entities.StudentThriftObject$StudentThriftObjectStandardScheme.read(StudentThriftObject.java:486)
      at com.vanilla.thrift.example.entities.StudentThriftObject$StudentThriftObjectStandardScheme.read(StudentThriftObject.java:479)
      at com.vanilla.thrift.example.entities.StudentThriftObject.read(StudentThriftObject.java:413)
      at com.vanilla.thrift.controller.Main.main(Main.java:24)
  </code></pre>
  
  <p>Am I missing something?</p>