FSharp.Data HTTP Utility RequestString 响应正文前缀为 "Text"
FSharp.Data HTTP Utility RequestString response Body is prepended with the word "Text"
我正在对 returns 一些 json 的 api 进行简单的网络调用 (GET)。麻烦的是,我无法用 Newtonsoft(或其他方式)解析它,因为 HTTP Utility RequestString response.Body 前面加上单词 "Text".
Text
"[{"name":"10 Years","desc":"","descData":null,"closed":false ...
我该怎么做才能避免这种情况并将我的 json 字符串作为实际的 json 字符串?
如果你看一下 FSharp.Data Http Utils ResponseBody docs you will notice it returns a Discriminated Union 有 2 个选项。
所以你会想用这样的东西来处理它:
let myHttphandler resp =
match resp with
| Text txt -> txt |> customTextHandler
| Binary bytes -> bytes |> customBytesHandler
当然,如果您知道自己总会收到短信,请在 DU 中使用 _
。
您的 customTextHandler
函数可能会反序列化您的 json。
我正在对 returns 一些 json 的 api 进行简单的网络调用 (GET)。麻烦的是,我无法用 Newtonsoft(或其他方式)解析它,因为 HTTP Utility RequestString response.Body 前面加上单词 "Text".
Text
"[{"name":"10 Years","desc":"","descData":null,"closed":false ...
我该怎么做才能避免这种情况并将我的 json 字符串作为实际的 json 字符串?
如果你看一下 FSharp.Data Http Utils ResponseBody docs you will notice it returns a Discriminated Union 有 2 个选项。
所以你会想用这样的东西来处理它:
let myHttphandler resp =
match resp with
| Text txt -> txt |> customTextHandler
| Binary bytes -> bytes |> customBytesHandler
当然,如果您知道自己总会收到短信,请在 DU 中使用 _
。
您的 customTextHandler
函数可能会反序列化您的 json。