[GTALUG] Sending array variable over CGI ?
William Park
opengeometry at yahoo.ca
Sun May 13 00:57:09 EDT 2018
On Sat, May 12, 2018 at 08:38:23PM -0400, Jamon Camisso via talk wrote:
> On 2018-05-12 05:48 PM, William Park via talk wrote:
> > Hi all,
> >
> > If I'm sending single valued data over web, eg. a=111, b=222, c=333,
> > then I can do
> > http://.../xxx.cgi?a=111&b=222&c=333
> >
> > How do I send array data, like A[1]=111, A[2]=222, A[3]=333 to a CGI
> > script? I don't think I can do something like
> > http://.../xxx.cgi?A[1]=111&A[2]=222&A[3]=333
> > Or, can I?
> >
> > I have seen a same variable repeated,
> > http://.../xxx.cgi?A=111&A=222&A=333
> > but that means the CGI script has to build the array.
>
> If JSON is an option, it is pretty easy to do what you're after in
> javascript. For example, I've been working on a project using
> crypto.subtle in the browser. I generate a key and an IV with
> javascript, and it is easy to represent the arrays of bytes like you've
> specified.
>
>
> For example: I have an IV Uint8Array(16) that looks like this:
> Uint8Array(16) [ 147, 174, 163, 227, 241, 236, 204, 23, 159, 18, ??? ]
>
> As a string it looks like what you'd expect - iv.toString() shows:
> "147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153"
>
>
> Now what you're after with mapping in JSON (I've inserted line breaks):
> JSON.stringify(iv))
> {"0":147,"1":174,"2":163,"3":227,"4":241,"5":236,
> "6":204,"7":23,"8":159,"9":18,"10":218,
> "11":74,"12":177,"13":105,"14":214,"15":153}
>
>
> Alternatively, you can get an unkeyed array using Array.from() and
> converting that to JSON:
> JSON.stringify(Array.from(iv))
> "[147,174,163,227,241,236,204,23,159,18,218,74,177,105,214,153]"
>
> Any of that look useful?
What does URL look like, when sending those 16 integers?
Or, has Web/CGI evolved to a point where you just include JSON content
in POST method, and javascript handles the magic behind the scene?
--
William Park <opengeometry at yahoo.ca>
More information about the talk
mailing list