[
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Grant Sherrick updated THRIFT-5474:
-----------------------------------
Description:
There is an issue in the generation of JSON from the TSimpleJSONProtocol, where
if there are quotes inside of a string, then those quotes will not be
serialized correctly. These quotes need one more layer of escaping to produce
valid JSON.
For instance, if you have the Thrift structure defined by:
{code:java}
struct MyThriftStruct {
1: required string my_string
}
{code}
And, I then define an object of that type in Java:
{code:java}
MyThriftStruct t = new MyThriftStruct();
t.my_string = "I said: \"this is a fairly nice string.\""{code}
And, if I then serialize this using the TSimpleJsonProtocol in this manner:
{code:java}
TSerializer thriftJsonSer = new TSerializer(new TSimpleJSONProtocol.Factory());
String myThriftStructJsonString = return thriftJsonSer.toString(t);
{code}
This will result in JSON that cannot be deserialized because the quotes inside
of the string were not escaped properly.
was:
There is an issue in the generation of JSON from the TSimpleJSONProtocol, where
if there are quotes inside of a string, then those quotes will not be
serialized correctly. These quotes need one more layer of escaping to produce
valid JSON.
For instance, if you have the Thrift structure defined by:
{code:java}
struct MyThriftStruct {
1: required string my_string
}
{code}
And, I then define an object of that type in Java:
{code:java}
MyThriftStruct t = new MyThriftStruct();
t.my_string = "I said: \"this is a fairly nice string.\""{code}
And, if I then serialize this using the TSimpleJsonProtocol in this manner:
{code:java}
TSerializer thriftJsonSer = new TSerializer(new
TNotSoSimpleJSONProtocol.Factory());
String myThriftStructJsonString = return thriftJsonSer.toString(t);
{code}
This will result in JSON that cannot be deserialized because the quotes inside
of the string were not escaped properly.
> TSimpleJsonProtocol serialization on string with inner quotes does not
> produce valid JSON.
> ------------------------------------------------------------------------------------------
>
> Key: THRIFT-5474
> URL: https://issues.apache.org/jira/browse/THRIFT-5474
> Project: Thrift
> Issue Type: Bug
> Components: Java - Library
> Reporter: Grant Sherrick
> Priority: Minor
> Time Spent: 20m
> Remaining Estimate: 0h
>
> There is an issue in the generation of JSON from the TSimpleJSONProtocol,
> where if there are quotes inside of a string, then those quotes will not be
> serialized correctly. These quotes need one more layer of escaping to produce
> valid JSON.
>
> For instance, if you have the Thrift structure defined by:
>
> {code:java}
> struct MyThriftStruct {
> 1: required string my_string
> }
> {code}
>
> And, I then define an object of that type in Java:
> {code:java}
> MyThriftStruct t = new MyThriftStruct();
> t.my_string = "I said: \"this is a fairly nice string.\""{code}
>
> And, if I then serialize this using the TSimpleJsonProtocol in this manner:
> {code:java}
> TSerializer thriftJsonSer = new TSerializer(new
> TSimpleJSONProtocol.Factory());
> String myThriftStructJsonString = return thriftJsonSer.toString(t);
> {code}
>
> This will result in JSON that cannot be deserialized because the quotes
> inside of the string were not escaped properly.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)