json - How do I append data to a JObject in C#? -


so in c# have created following json:

{ "timeline": {     "headline": "development timeline",     "type": "default",     "text": "timeline",     "startdate": "12/12/2011",     "date": [         {             "startdate": "2012,02,15",             "enddate": "2012,04,19",             "headline": "development",             "text": "coding"         },         {             "startdate": "2012,04,19",             "enddate": "2012,07,25",             "headline": "development",             "text": "coding"         },         {             "startdate": "2012,07,25",             "enddate": "2012,10,26",             "headline": "development",             "text": "coding"         }     ] } 

}

using jobject:

                jjson = new jobject(                new jobject(                 new jproperty("timeline",                     new jobject(                     new jproperty("headline", "development"),                     new jproperty("type", "default"),                     new jproperty("text", "timeline"),                     new jproperty("startdate", "12/12/2011"),                     new jproperty("date",                         new jarray(                         p in timelinelist                         orderby p.releasedate                         select new jobject(                             new jproperty("startdate", p.startdate),                             new jproperty("enddate", p.enddate),                             new jproperty("headline", p.headline),                             new jproperty("text", p.text))                                                             )))))); 

now wish add section in date[] of json object startdate/enddate cant seem able :(

i have tried create jarray test , see if append json no luck error of: "reference not set instance of object:

jarray dd = new jarray(); dd = (jarray) jjson["date"]; dd.add("item 1,sdsds"); 

how can add property created json? thank you

from example jjson not contain date property, contains timeline property, in case should ((jsonobject)jjson["timeline"])["date"]


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -