Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

valuestring parse is truncated #93

Open
b-rohit opened this issue Jul 2, 2019 · 1 comment
Open

valuestring parse is truncated #93

b-rohit opened this issue Jul 2, 2019 · 1 comment

Comments

@b-rohit
Copy link

b-rohit commented Jul 2, 2019

I use JWT token for REST api on my server. I am able to parse correctly, but when I access of token using valuestring, it doesn't give complete value of the token, it is truncated. I received the following response from server.
{"token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InJib2hyYSIsImlhdCI6MTU2MjA3NTE0NCwiZXhwIjoxNTYyMDc1MjA0fQ.jIimgiWP9fCJ8I31Bof_wxSawBr7fa8JBeSQDnl8zHyILCfdlNW-P-4swDQEIbqRXDt3U3nngw0F_VgOv2DcSulW_U1WnCLbHTQnaP9RDW4g2OSqqAdqrw7_qbey8grDjC8oQDZ6vLfI5MoP_5p5LocezSjeJkgorZAS9O9QU8Ib8Ggjwd6DUT-yhun93jQv_VTnY24V_ayQHXvohZFreDSB3oLDa-8xH1NDxUupVB8euuXs8lXsqxyQhH-O7-jA5kOeRnYtL8rSEkXRXyrej0r7iS9HqkodfQ9BN9O3FoKcaISsBp_zYlCFiPqHpFGARVQMJhmspLoiK7NFUIj-1Q"}

I parsed it this way..

aJsonObject* jresult = aJson.parse(buff);
aJsonObject* jwt = aJson.getObjectItem(jresult, "token");
const char *token = jwt->valuestring;

The token variable has following value.
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InJib2hyYSIsImlhdCI6MTU2MjA3NTE0NCwiZXhwIjoxNTYyMDc1MjA0fQ.jIimgiWP9fCJ8I31Bof_wxSawBr7fa8JBeSQDnl8zHyILCfdlNW-P-4swDQEIbqRXDt3U3nngw0F_VgOv2DcSulW_U1WnCLbHTQnaP9RDW4g2OSqqAdqrw7_qbey8grDjC8oQDZ6vLfI5MoP_5p5Loce

which is not complete value. How can I correct it?

@lulersoft
Copy link

lulersoft commented Jan 14, 2020

aJsonObject* jresult = aJson.parse(buff);
aJsonObject* jwt = aJson.getObjectItem(jresult, "token");
if(jwt!=NULL){
char *token = jwt->valuestring;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants