Last active
November 4, 2019 14:24
-
-
Save viniceosm/05137e864cbf51ada84d97620c79d3bb to your computer and use it in GitHub Desktop.
pegar JSON de um request em ASP classico
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
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