Get Classic ASP variable from posted JSON Get Classic ASP variable from posted JSON json json

Get Classic ASP variable from posted JSON


alphadogg's solution didn't work for me, I got errors with the line bStream.Write requestBody (saying "Operation is not allowed in this context.") This seems to work for me, and returns the whole request string. However, it will only work for request data <= 100 KB, otherwise you'll have to work out how to get the BinaryRead method working.

str = Request.Form

(Discovered from http://msdn.microsoft.com/en-us/library/ms525985%28v=VS.90%29.aspx)


alphadogg's code worked for me, but only after I specified a little more information:

bytecount = Request.TotalBytesbytes = Request.BinaryRead(bytecount)Set stream = Server.CreateObject("ADODB.Stream");stream.Type = 1;    // adTypeBinary              stream.Open();                                   stream.Write(bytes);stream.Position = 0;                             stream.Type = 2;    // adTypeText                stream.Charset = "utf-8";                        Set s = stream.ReadText();                       stream.Close();                                  

Prior to this I would get "Operation is not allowed in this context." as jjokin reported.


Here is the solution that i used in ASP Vbscript with Radium's code and some corrections:

bytecount = Request.TotalBytesbytes = Request.BinaryRead(bytecount)Set stream = Server.CreateObject("ADODB.Stream")    stream.Type = 1 'adTypeBinary                  stream.Open()                                           stream.Write(bytes)        stream.Position = 0                                     stream.Type = 2 'adTypeText                        stream.Charset = "utf-8"                              s = stream.ReadText() 'here is your json as a string                    stream.Close()Set stream = nothingResponse.write(s)