B4J Question With httpjob Post json to jServer(server handler)

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
I use following code post a json to jserver. What function could let me read json via ServletRequest ? o_O

B4X:
Dim sn As Map=jyAuth.LoadMachineSn
    sn.Put("license",result)           
    Dim jg As JSONGenerator
    jg.Initialize(sn)
    Dim HTTPTask As HttpJob
    HTTPTask.Initialize("HTTPTask", Me)
    HTTPTask.PostString("http://127.0.0.1:8168/registered", jg.ToString)
    HTTPTask.GetRequest.SetContentType("application/json")
    HTTPTask.GetRequest.SetHeader("Accept","application/json")
    wait for (HTTPTask) JobDone(HTTPTask As HttpJob)   
    If HTTPTask.Success Then
        'Json.Initialize(HTTPTask.GetString)
        Log(HTTPTask.GetString)
    End If
HTTPTask.Release
 

aeric

Expert
Licensed User
Longtime User
B4X:
Dim StreamReader As TextReader
StreamReader.Initialize(req.InputStream)  
Dim parser As JSONParser
parser.Initialize(StreamReader.ReadAll)
Log(parser.NextObject)
 
Upvote 0
Top