Newtonsoft.json.jsonserializer出现双引号问题

时间:2020-03-03 23:41:01

标签: .net vb.net json.net

我正在使用序列化方法将对象转换为JSON,并且JSON出现在双引号中。我是否缺少转义方法?

$ ./bin/prefixaverage dat/prefixdouble.txt hhhh
prefix 'hhhh' avg: 0.8874

$ ./bin/prefixaverage dat/prefixdouble.txt xxxx
prefix 'xxxx' avg: 0.9105

$ ./bin/prefixaverage dat/prefixdouble.txt yyyy
prefix 'yyyy' avg: 0.7962

$ ./bin/prefixaverage dat/prefixdouble.txt zzzz
prefix 'zzzz' avg: 0.7897

$ ./bin/prefixaverage dat/prefixdouble.txt foo
prefix 'foo' -- not found in file.

我的输出看起来像

from msrestazure.azure_active_directory import AADTokenCredentials
import adal, uuid, time

authority_host_uri = "https://login.microsoftonline.com"
tenant_id = "..."
client_id = "..."
authority_uri = authority_host_uri + '/' + tenant_id
resource_uri = "https://storage.azure.com/"
context = adal.AuthenticationContext(authority_uri, api_version=None)
code = context.acquire_user_code(resource_uri, client_id)
print(code['message'])

mgmt_token = context.acquire_token_with_device_code(resource_uri, code, client_id)
credentials = AADTokenCredentials(mgmt_token, client_id)

1 个答案:

答案 0 :(得分:2)

您看到的是逐字字符串文字,其中的引号必须通过加倍来转义。输出没有问题,它只是在调试器中显示双引号,但是如果您将其写入文件或发送给API,则不会将它们加倍。

编辑:有关更多上下文,请参阅此问题。显然,VB.NET中的所有字符串都是逐字字符串文字:How to do a verbatim string literal in VB.NET?

相关问题