[jira] [Comment Edited] (THRIFT-5474) TSimpleJsonProtocol serialization on string with inner quotes does not produce valid JSON.

2021-10-29 Thread Grant Sherrick (Jira)


[ 
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17435733#comment-17435733
 ] 

Grant Sherrick edited comment on THRIFT-5474 at 10/29/21, 1:59 PM:
---

Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization to a JSON string using 
TSimpleJSONProtocol.

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The quotes that are 
internal to the string must be escaped twice because otherwise they close the 
string itself.

The string being produced here is being closed prematurely because the internal 
quotes are not being escaped twice. That is the behavior that I am seeing when 
using this in the manner that is described in the description above.


was (Author: thealmightygrant):
Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol in my pull request. If the parsing fails, it will 
throw a [JsonParseException|#createParser(java.lang.String)]. 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|#L312]. However, the quotes that are internal to the string must be 
escaped twice because otherwise they close the string itself. Does that make 
sense to you? The string being produced here is being closed prematurely 
because the internal quotes are not being escaped twice.

> 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)


[jira] [Comment Edited] (THRIFT-5474) TSimpleJsonProtocol serialization on string with inner quotes does not produce valid JSON.

2021-10-28 Thread Grant Sherrick (Jira)


[ 
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17435733#comment-17435733
 ] 

Grant Sherrick edited comment on THRIFT-5474 at 10/29/21, 1:21 AM:
---

Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol in my pull request. If the parsing fails, it will 
throw a [JsonParseException|#createParser(java.lang.String)]. 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|#L312]. However, the quotes that are internal to the string must be 
escaped twice because otherwise they close the string itself. Does that make 
sense to you? The string being produced here is being closed prematurely 
because the internal quotes are not being escaped twice.


was (Author: thealmightygrant):
Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol in my pull request. If the parsing fails, it will 
throw a [JsonParseException|#createParser(java.lang.String)]. 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|#L312].] However, the quotes that are internal to the string must be 
escaped twice because otherwise they close the string itself. Does that make 
sense to you? The string being produced here is being closed prematurely 
because the internal quotes are not being escaped twice.

> 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)


[jira] [Comment Edited] (THRIFT-5474) TSimpleJsonProtocol serialization on string with inner quotes does not produce valid JSON.

2021-10-28 Thread Grant Sherrick (Jira)


[ 
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17435733#comment-17435733
 ] 

Grant Sherrick edited comment on THRIFT-5474 at 10/29/21, 1:21 AM:
---

Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol in my pull request. If the parsing fails, it will 
throw a [JsonParseException|#createParser(java.lang.String)].] 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|#L312].] However, the quotes that are internal to the string must be 
escaped twice because otherwise they close the string itself. Does that make 
sense to you? The string being produced here is being closed prematurely 
because the internal quotes are not being escaped twice.


was (Author: thealmightygrant):
Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift and serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol. If the parsing fails, it will throw a 
[JsonParseException|[https://fasterxml.github.io/jackson-core/javadoc/2.6/com/fasterxml/jackson/core/JsonFactory.html#createParser(java.lang.String)].]
 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|[https://github.com/apache/thrift/blob/master/lib/java/src/org/apache/thrift/protocol/TSimpleJSONProtocol.java#L312].]
 However, the quotes that are internal to the string must be escaped twice 
because otherwise they close the string itself. Does that make sense to you? 
The string being produced here is being closed prematurely because the internal 
quotes are not being escaped twice.

> 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)


[jira] [Comment Edited] (THRIFT-5474) TSimpleJsonProtocol serialization on string with inner quotes does not produce valid JSON.

2021-10-28 Thread Grant Sherrick (Jira)


[ 
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17435733#comment-17435733
 ] 

Grant Sherrick edited comment on THRIFT-5474 at 10/29/21, 1:21 AM:
---

Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol in my pull request. If the parsing fails, it will 
throw a [JsonParseException|#createParser(java.lang.String)]. 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|#L312].] However, the quotes that are internal to the string must be 
escaped twice because otherwise they close the string itself. Does that make 
sense to you? The string being produced here is being closed prematurely 
because the internal quotes are not being escaped twice.


was (Author: thealmightygrant):
Ahhh, sorry about including {{TNotSoSimpleJSONProtocol}} in this description, I 
needed to name my fork something in my local repo. That is my mistake.  I'll 
update the original description.

When I tested this against both jackson and PHP's json_decode, I get the same 
error when trying to deserialize the String that is output from the above 
thrift message and the resulting serialization using TSimpleJSONProtocol.

I tried to reproduce this by adding some jackson JSON parsing to each of the 
tests for TSimpleJSONProtocol in my pull request. If the parsing fails, it will 
throw a [JsonParseException|#createParser(java.lang.String)].] 

The issue here is that double quotes must be treated differently than other 
escape characters because JSON values that are strings are surrounded in double 
quotes, and these quotes are escaped a single time. The first double quote 
surrounding the string itself is escaped a single time here and can be seen 
[here|#L312].] However, the quotes that are internal to the string must be 
escaped twice because otherwise they close the string itself. Does that make 
sense to you? The string being produced here is being closed prematurely 
because the internal quotes are not being escaped twice.

> 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)


[jira] [Comment Edited] (THRIFT-5474) TSimpleJsonProtocol serialization on string with inner quotes does not produce valid JSON.

2021-10-28 Thread Jens Geyer (Jira)


[ 
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17435708#comment-17435708
 ] 

Jens Geyer edited comment on THRIFT-5474 at 10/28/21, 11:00 PM:


Questions:
 * What is {{TNotSoSimpleJSONProtocol}}?
 * This will result in JSON that cannot be deserialized because ... can you 
show the JSON?


was (Author: jensg):
Questions:
* What is {{TNotSoSimpleJSONProtocol}}?
* This will result in JSON that cannot be deserialized because ... can you show 
it?

> 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 
> 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. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (THRIFT-5474) TSimpleJsonProtocol serialization on string with inner quotes does not produce valid JSON.

2021-10-28 Thread Jens Geyer (Jira)


[ 
https://issues.apache.org/jira/browse/THRIFT-5474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17435708#comment-17435708
 ] 

Jens Geyer edited comment on THRIFT-5474 at 10/28/21, 11:00 PM:


Questions:
* What is {{TNotSoSimpleJSONProtocol}}?
* This will result in JSON that cannot be deserialized because ... can you show 
it?


was (Author: jensg):
What is {{TNotSoSimpleJSONProtocol}}?

> 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 
> 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. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)