You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Will Fould <wi...@gmail.com> on 2007/10/23 22:18:06 UTC
stringified enumeration
I realise this may not be the most appropriate list for this question:
I need to internally enumerate (delimit) href name/value pairs.
Is there are "standardly acceptable" way to do this?
http://www.example.com/?fruit::1=grape&fruit::2=apple&fruit::3=banana&color::1=purple&color::2=red&color::3=yellow
thank you in advance.
(w)
Re: stringified enumeration
Posted by Michael Peters <mp...@plusthree.com>.
Will Fould wrote:
> I realise this may not be the most appropriate list for this question:
>
> I need to internally enumerate (delimit) href name/value pairs.
>
> Is there are "standardly acceptable" way to do this?
>
> http://www.example.com/?fruit::1=grape&fruit::2=apple&fruit::3=banana&color::1=purple&color::2=red&color::3=yellow
> <http://www.example.com/?fruit::1=grape&fruit::2=apple&fruit::3=banana&color::1=purple&color::2=red&color::3=yellow>
I've been using JSON recently for all my serialization needs. It would of course
need to be URL encoded.
I can't tell whether you're trying to get a structure like this:
{
fruit : ['grape', 'apple', 'banana' ],
color : ['purple', 'red', 'yellow' ]
}
or like this:
{
grape => 'purple',
apple => 'red',
banana => 'yellow',
}
I'm assuming the latter. The JSON looks like this (generating this JSON is
really easy if you're using a modern JavaScript framework).
{
grape : 'purple',
apple : 'red',
banana : 'yellow'
}
And the URL will look like
http://www.example.com?fruit=%7Bgrape%3A'purple'%2Capple%3A'red'%2Cbanana%3A'yellow'%7D
And then you can use JSON, or JSON::XS, JSON::Syck or whatever JSON module you
want from CPAN to deserialize it into a Perl structure on your server side.
--
Michael Peters
Developer
Plus Three, LP