I’m using Java-JSON for parsing and creating JSON payloads to send/receive from an API. Everything works fine until I get to this specific server payload, below is the result of System.out.println(payload)
where payload
is a String
:
<code>{"command-success":true,"command-error-code":"","command-error-message":"","command-result-type":"JWE","command-result":"eyJjdHkiOiJKV0UiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiYWxnIjoiUlNBLU9BRVAtMjU2In0.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx"}
<code>{"command-success":true,"command-error-code":"","command-error-message":"","command-result-type":"JWE","command-result":"eyJjdHkiOiJKV0UiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiYWxnIjoiUlNBLU9BRVAtMjU2In0.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx"}
</code>
{"command-success":true,"command-error-code":"","command-error-message":"","command-result-type":"JWE","command-result":"eyJjdHkiOiJKV0UiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwiYWxnIjoiUlNBLU9BRVAtMjU2In0.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx.xxxxxxxxxx"}
I only kept the header of the JWE for privacy reasons, but apart from that this is exactly the output of System.out.println(payload)
.
After I created a JSONObject
from this, I got all kinds of errors in the following code saying that it couldn’t find the JSON’s fields, and when I tried to print it with System.out.println(jsonObject.toString())
to see what was going on, I got this nonsense:
<code>{"blank":false,"bytes":[123,34,99,111,109,109,97,110,100,45,115,117,99,99,101,115,115,34,58,116,114,117,101,44,34,99,111,109,109,97,110,100,45,101,114,114,111,114,45,99,111,100,101,34,58,34,34,44,34,99,111,109,109,97,110,100,45,101,114,114,111,114,45,109,101,115,115,97,103,101,34,58,34,34,44,34,99,111,109,109,97,110,100,45,114,101,115,117,108,116,45,116,121,112,101,34,58,34,74,87,69,34,44,34,99,111,109,109,97,110,100,45,114,101,115,117,108,116,34,58,34,101,121,74,106,100,72,107,105,79,105,74,75,86,48,85,105,76,67,74,108,98,109,77,105,79,105,74,66,77,106,85,50,81,48,74,68,76,85,104,84,78,84,69,121,73,105,119,105,89,87,120,110,73,106,111,105,85,108,78,66,76,85,57,66,82,86,65,116,77,106,85,50,73,110,48,46,...],"empty":false}
<code>{"blank":false,"bytes":[123,34,99,111,109,109,97,110,100,45,115,117,99,99,101,115,115,34,58,116,114,117,101,44,34,99,111,109,109,97,110,100,45,101,114,114,111,114,45,99,111,100,101,34,58,34,34,44,34,99,111,109,109,97,110,100,45,101,114,114,111,114,45,109,101,115,115,97,103,101,34,58,34,34,44,34,99,111,109,109,97,110,100,45,114,101,115,117,108,116,45,116,121,112,101,34,58,34,74,87,69,34,44,34,99,111,109,109,97,110,100,45,114,101,115,117,108,116,34,58,34,101,121,74,106,100,72,107,105,79,105,74,75,86,48,85,105,76,67,74,108,98,109,77,105,79,105,74,66,77,106,85,50,81,48,74,68,76,85,104,84,78,84,69,121,73,105,119,105,89,87,120,110,73,106,111,105,85,108,78,66,76,85,57,66,82,86,65,116,77,106,85,50,73,110,48,46,...],"empty":false}
</code>
{"blank":false,"bytes":[123,34,99,111,109,109,97,110,100,45,115,117,99,99,101,115,115,34,58,116,114,117,101,44,34,99,111,109,109,97,110,100,45,101,114,114,111,114,45,99,111,100,101,34,58,34,34,44,34,99,111,109,109,97,110,100,45,101,114,114,111,114,45,109,101,115,115,97,103,101,34,58,34,34,44,34,99,111,109,109,97,110,100,45,114,101,115,117,108,116,45,116,121,112,101,34,58,34,74,87,69,34,44,34,99,111,109,109,97,110,100,45,114,101,115,117,108,116,34,58,34,101,121,74,106,100,72,107,105,79,105,74,75,86,48,85,105,76,67,74,108,98,109,77,105,79,105,74,66,77,106,85,50,81,48,74,68,76,85,104,84,78,84,69,121,73,105,119,105,89,87,120,110,73,106,111,105,85,108,78,66,76,85,57,66,82,86,65,116,77,106,85,50,73,110,48,46,...],"empty":false}
Same here, I only kept the header of the JWE for privacy reasons.
But why does it make this array of bytes instead of correctly parsing the JSON?