3 ms·
_foo_bar=Something&baz=Else could parse as either of: {foo:{bar:"Something",baz:"Else"}} {foo:{bar:"Something"}, baz:"Else"} which seems to ruin things.
by Robin_Message 15y ago
_foo_bar=Something&baz=Else
could parse as either of:
{foo:{bar:"Something",baz:"Else"}}
{foo:{bar:"Something"}, baz:"Else"}
which seems to ruin things. You need a character to end an object, maybe ; or & would work.
Also, I don't like using : in query strings as a separator since that makes it a bit ugly and not quite a query string.
How about using = for both and using say ! to identify non-strings, and @item@item@item for arrays?
So your example becomes:
_user_name=Bob%20Smith&age=!47&sex=M&dob=5/12/1956&pastimes=@golf@opera@poker@rap&;children_bobby_age=!12&sex=M&;sally_age=!8&sex=F
- vjeux 15y agoI thought that I could get away without terminations for objects & arrays but I was wrong. I've added ; as you suggested. I made it safe to remove ; at the end in order to keep size small for flat structures. @item1@item2@item3 is a really good idea. It's added :)
- vaporstun 15y ago> _foo_bar=Something&baz=Else > could parse as either of: > {foo:{bar:"Something",baz:"Else"}} > {foo:{bar:"Something"}, baz:"Else"} I don't think this is right, or at least, it shouldn't be right. I think _foo_bar=Something&baz=Else should only parse as {foo:{bar:"Something"}, baz:"Else"}. {foo:{bar:"Something",baz:"Else"}} should be _foo_bar=Something&_foo_baz=Else It should be possible for the writer of the article to fix this without major changes.
- Robin_Message 15y ago> {foo:{bar:"Something",baz:"Else"}} should be _foo_bar=Something&_foo_baz=Else This makes sense, but is not what I or the author was suggesting. Note that it is somewhat repetitive (foo appears twice). In contrast the new suggestion simply has an possible ; to disambiguate these possibilities.