我想知道是否可以使用 GET 请求从服务器获取 JSON 文本,然后将该数据以 JSON 格式输出到本地文件中。
我似乎唯一能找到的是这个电话:
File.WriteAllText(AgentWorkingDirectory & "\json.txt", JsonConvert.SerializeObject(return_message))`
Run Code Online (Sandbox Code Playgroud)
这似乎只给了我一行连续的未格式化的文本。
所以代替这个:
{
"AlertingRules":[
{
"RuleId":1,
"Name":"Unprocessed Directory",
"RuleConditions":[
{
"Name":"FileCount",
"FileName":"",
...
Run Code Online (Sandbox Code Playgroud)
我明白了:
{"AlertingRules":[{"RuleId":1,"Name":"Unprocessed Directory","RuleConditions":[{"Name":"FileCount","FileName":null,...
Run Code Online (Sandbox Code Playgroud)
将格式化参数添加到序列化调用中
File.WriteAllText(AgentWorkingDirectory & "\json.txt",JsonConvert.SerializeObject(return_message, Newtonsoft.Json.Formatting.Indented))
Run Code Online (Sandbox Code Playgroud)
请参阅Json.NET 文档
| 归档时间: |
|
| 查看次数: |
6825 次 |
| 最近记录: |