我正在尝试在我的asp.net web forms应用程序中以json格式从MS SQL导出数据。问题是它在导出时使用两个双引号将值括起来,而不是只有一个双引号。我希望它像这样导出:
{"bizunitid":"11111","prodlineid":"1","reasonforsurvey":"1"}
但它是这样出来的:
"{""bizunitid"":""11111"",""prodlineid"":""1"",""reasonforsurvey"":""2""}"
我尝试替换两个双引号,但总是返回两个双引号。
Dim json As String = cmd.ExecuteScalar
streamWriter.Write(json.Replace("""""", Chr(34)))
发布于 2019-09-03 08:51:38
我不确定这是否是你想要的,但这就是我在使用VB.Net将JSon发布到一个消息应用的应用程序接口时所做的:
MessageTitle = MessageTitle.Replace("""", """""")
MessageBody = MessageBody.Replace("""", """""")
Dim strPostData As String = "{" &
"""notification"": {" &
"""sound"": ""default""," &
"""title"": """ & MessageTitle & """," &
"""body"": """ & MessageBody & """" &
"}, " &
"""data"": {" &
"""title"": """ & MessageTitle & """," &
"""body"": """ & MessageBody & """" &
"}," &
"""to"": """ & strRegIDs & """," &
"""priority"": 10 " &
"}"
希望这能帮上点忙
https://stackoverflow.com/questions/57403570
复制