相关疑难解决方法(0)

json.net有关键方法吗?

如果我的回复有关键"错误",我需要处理错误并显示警告框.

json.net中是否存在"haskey"方法?喜欢:

var x= JObject.Parse(string_my);
if(x.HasKey["error_msg"])
    MessageBox.Show("Error!")
Run Code Online (Sandbox Code Playgroud)

c# json json.net

135
推荐指数
3
解决办法
9万
查看次数

将JSON.NET JObject的属性/标记转换为字典键

我正在使用JSON.NET使用.NET解析来自openexhangerates.org服务器端的JSON响应.响应包含一个嵌套对象("rates"),它有一长串数字属性:

    {
    "disclaimer": "Exchange rates provided for informational purposes only, with no guarantee whatsoever of accuracy, validity, availability, or fitness for any purpose; use at your own risk. Other than that, have fun! Usage subject to acceptance of terms: http://openexchangerates.org/terms/",
    "license": "Data sourced from various providers with public-facing APIs; copyright may apply; not for resale; no warranties given. Usage subject to acceptance of license agreement: http://openexchangerates.org/license/",
        "timestamp": 1357268408,
        "base": "USD",
        "rates": {
            "AED": 3.673033,
            "AFN": 51.5663,
            "ALL": 106.813749,
            "AMD": 403.579996, …
Run Code Online (Sandbox Code Playgroud)

.net c# json.net

21
推荐指数
2
解决办法
3万
查看次数

获取JSON对象的绝对路径

我有一个 JSON 对象:

{
  ""settings"": {
    ""general"": {
      ""database"": { ""type"": ""PostgreSql"" }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我的 JSON 对象的绝对路径如下所示:settings/general/database/type

我试图用这个问题的第一个解决方案获取所有密钥:

IList<string> keys = parent.Properties().Select(p => p.Name).ToList();
Run Code Online (Sandbox Code Playgroud)

这对我不起作用。该keys列表只包含第一个密钥settings,没有其他密钥。

有一个path属性显示您所在节点的路径,但它不显示 JSON 对象的完整路径。

在此输入图像描述

如何获得像我的示例中那样的绝对路径?

c# json json.net

0
推荐指数
1
解决办法
4332
查看次数

标签 统计

c# ×3

json.net ×3

json ×2

.net ×1