【问题标题】:How to decode a gzip encoded JSON using Lotus-Script如何使用 Lotus-Script 解码 gzip 编码的 JSON
【发布时间】:2019-07-04 15:27:55
【问题描述】:

我从 httprequest 获取 gzip 编码的 JSON 内容,但我不知道如何在 Lotus Script 中对其进行解码。

Set webRequest = Session.createhttprequest()


    Call webRequest.Setheaderfield("cache-control", "no-cache")
    Call webRequest.Setheaderfield("Connection", "keep-alive")
    Call webRequest.Setheaderfield("Content-Type", "application/json")
    Call webRequest.Setheaderfield("Authorization", "Bearer " + accessToken)
    Call webRequest.Setheaderfield("Accept", "*/*")
    Call webRequest.Setheaderfield("Host", "graph.microsoft.com")
    Call webRequest.Setheaderfield("accept-encoding", "gzip, deflate")

ret = webRequest.Get(Url)

ForAll b In ret
    responsJSON = responsJSON + Chr(b)
End ForAll

Set jsnav = session.CreateJSONNavigator(responsJSON)

我期望一个 JSON,但收到此错误消息“无法解析 JSON 字符串:无效值。Offset0”

【问题讨论】:

    标签: json httprequest gzip lotusscript


    【解决方案1】:

    您使用的是哪个版本的 Domino/Notes?尝试 10.0.1 FP2 并使用 set webRequest.PreferJSONNavigator = true。这将直接重新调整 JSONNavigator,并将跳过https://www-01.ibm.com/support/docview.wss?uid=ibm10875724 中确定的一些问题

    【讨论】:

    • 好的,它可以工作,但如果我不在标题中设置它Call webRequest.Setheaderfield("accept-encoding", "gzip, deflate") 对我来说似乎有点连线。 webRequest.PreferJSONNavigator = true 这有帮助。是的,我在 10.0.1 FP2 上。 TY
    猜你喜欢
    • 2015-01-17
    • 1970-01-01
    • 1970-01-01
    • 2011-02-11
    • 2019-05-25
    • 2021-11-30
    • 1970-01-01
    • 2015-07-10
    • 1970-01-01
    相关资源
    最近更新 更多