JSON字符串化字典

时间:2017-04-18 15:53:49

标签: c# json tfs build

我试图通过JSON在TFS 2017上开始构建,如下例所示: https://www.visualstudio.com/en-us/docs/integrate/api/build/builds#queue-a-build

这是我的JSON:

{
"definition": 
{
    "id": 167
},
"sourceBranch": "refs/heads/master",
"parameters": "{\"system.debug\":\"false\",\"BuildConfiguration\":\"release\",\"BuildPlatform\":\"any cpu\",\"PushInfoXmlFilePath\":\"\\\\08tfs02\\PushInformation\\PushInfo896.xml\"}"
}

查看事件日志,我看到了这个例外:

  

Newtonsoft.Json.JsonReaderException:错误的JSON转义序列:\ P.   Path' PushInfoXmlFilePath',第1行,第115位。

我尝试用简单的 \" test \替换网络路径 \" \\ 08tfs02 \ PushInformation \ PushInfo896.xml \" " 然后它可以正常工作。

如何使其与网络路径一起使用?

1 个答案:

答案 0 :(得分:0)

为json文件尝试以下格式:

{
  "definition": {
    "id": 167
  },
  "Parameters": {
    "system.debug": "false",
    "BuildConfiguration": "release",
    "BuildPlatform": "any cpu",
    "PushInfoXmlFilePath": "\\\\08tfs02\\PushInformation\\PushInfo896.xml"
  }
}

您最好不要将所有参数放在一行中。