Skip to content

Instantly share code, notes, and snippets.

@viniceosm
Last active November 4, 2019 14:24
Show Gist options
  • Save viniceosm/05137e864cbf51ada84d97620c79d3bb to your computer and use it in GitHub Desktop.
Save viniceosm/05137e864cbf51ada84d97620c79d3bb to your computer and use it in GitHub Desktop.
pegar JSON de um request em ASP classico
<%
function requestToJsonString()
bytecount = Request.TotalBytes
bytes = 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"
jsonStringRequest = stream.ReadText() ' seu json como string
stream.Close()
Set stream = nothing
requestToJsonString = jsonStringRequest
end function
jsonStringRequest = requestToJsonString()
Response.write(jsonStringRequest) ' imprima seu json string
' Depois poderá fazer o parse, usando alguma biblioteca
' uma biblioteca que faz parse: https://github.com/rcdmk/aspJSON
%>
<!-- #include virtual="jsonObject.class.asp" -->
<%
Response.LCID = 1046
set JSON = new JSONobject
set oJSON = JSON.Parse(jsonStringRequest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment