javascript - PHP's json_encode and JS's JSON.stringify -


i'm using both php , javascript build kind of web service. try validate token calculated on post parameters, sent js php. let's code follows:

js :

token = json.stringify(params); 

php :

token = json_encode($_post); 

can please explain me why 2 resulting json strings doesn't have same length ?

(i tried trim \n\r\t in php, stripslashes in php, several js libs) php version of string have more characters.

in javascript, json key without quote valid. in php, json key without quote not valid. (in fact, right json syntax quotes on keys.)

so you’re right, difference came json.stringify strip quotes integer key.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -