Read Json Value from cookie in java.
Hi, I want to get and decode a cookie in java, which is set in JavaScript. while trying to get the cookie this error occurred Json Exception::A JSONObject text must begin with '{' at 1 [character 2 line 1].
This is decoded JSON which is encoded in JavaScript.
{
"name": "prodname",
"quantity": 4
}To decode the cookie, we have used base64 decoder.
final Cookie cookie = getCookie(request, "XYZ");
JsonObject cookieJson = new JsonParser().parse(new String(Base64.getDecoder().decode(cookie.getValue()))).getAsJsonObject();
Kindly anyone help to fix this. Thanks in advance!