Click here to Skip to main content
15,888,037 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using HTTP post method to catch data from a client...

so when using HTTP POST is it better to send the data string using splitters or json?

and why?
Posted

1 solution

In json you'd pass something like
JavaScript
{"id":12, "firstname":"pascal","lastname":"ganaye"}

Whereas with a splitter
JavaScript
12|Pascal|GANAYE


Json is
* easy : you can find a library to write and parse it
* standard : it is a documented standard, so people who understand json will understand easily
* extensible : by design json is extensible you can easily add more data and even complex data later.

A splitter is
* even easier : you can use string.split string.join
* compact: the | version is shorter
* dangerous : what if you have a delimiter in your data
* obscure : 12|Pascal|GANAYE is less human readable than the json version
* less extensible : the splitter won't allow you to pass arrays or inner objects
* riskier : if you insert an extra parameter at the beginning as the parameters are not name there is more mismatch risks.

Overall if the volume of what you send is not too big I would stick with json.
Only if you're sending megabytes and speed is paramount then I might consider something else but then not a splitter but something binary.
 
Share this answer
 
v3
Comments
thatraja 17-Oct-13 6:17am    
Nice, 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900