JObject nested property

前端 未结 2 1368
一整个雨季
一整个雨季 2021-02-13 20:11

I am trying to make a json object like this with JObject:

{
    \"input\": {
        \"webpage/url\": \"http://google.com/\"
    }
}

I can add

2条回答
  •  不要未来只要你来
    2021-02-13 21:00

    Just carry on as you are, and nest them in another level:

    JObject job = new JObject(
                    new JProperty("website/url", "http://www.google.com") );
    
    JObject parent = new JObject(new JProperty("input", job));
    

    parent.ToString() now gives:

    { "input": { "website/url": "http://www.google.com" } }

提交回复
热议问题