简体   繁体   English

如何在c#中创建json到json对象?

[英]How to make json to json object in c#?

I have a json wants to add square brackets on it (means wants to convert it to json object array) here is my json in response, 我有一个json想在其上添加方括号(意味着要将其转换为json对象数组)这里是我的json响应,

    {
  "exampleJson": {
    "test": [
      {
        "xf": "G",
        "sas": "24",
        "ras": 5,
        "asd": 4000,
        "rer": 200,
        "asda": 0
      },
    ],
  }
}  

Now i want this json to as below (Just square brackets before and to the end of the json) 现在我希望这个json如下所示(在json之前和之后只需方括号)

    [{
  "exampleJson": {
    "test": [
      {
        "xf": "G",
        "sas": "24",
        "ras": 5,
        "asd": 4000,
        "rer": 200,
        "asda": 0
      },
    ],
  }
}]

Apart from concatenation is there any way to achieve this ? 除了连接之外还有什么办法可以达到这个目的吗? And this is a JObject which i have created. 这是我创建的JObject

JArray []表示正在返回一个数组而不是一个对象,因此您需要将外部容器设为JArray

var returnedArray = new JArray(jObject);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM