by Robin_Message · 15y ago · 0 comments
_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> 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.
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.
@item1@item2@item3 is a really good idea. It's added :)