Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Thrift Wiki" for change 
notification.

The following page has been changed by StuartSierra:
http://wiki.apache.org/thrift/ThriftUsageJava

The comment on the change is:
Added Simple JSON example.

------------------------------------------------------------------------------
- Assuming you're using the definitions in "tutorial.thrift":
+ '''Assuming you're using the definitions in "tutorial.thrift":'''
  
  == Importing the Classes ==
  
@@ -38, +38 @@

  byte[] bytes = serializer.serialize(work);
  }}}
  
+ == Serializing to "Simple" JSON ==
+ 
+ {{{
+ TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory());
+ String json = serializer.toString(work);
+ }}}
+ 
+ The "Simple" JSON protocol produces output suitable for AJAX or scripting 
languages.  It does not preserve Thrift's type information and cannot be read 
back in by Thrift.  Using the sample object created above, the output is:
+ 
+ {{{
+ {"num1":7,"num2":9,"op":1}
+ }}}
+ 

Reply via email to