c# - Adding items to List after reading from JSON -


i have json file reading data in , inserting list. following code read json file , insert list.

public class prepacklist {     public int prepackid;     public int stockid;     public string stockitem;     public int reservedupcid;     public string reservedupc;     public string weight;     public datetime packeddate;     public datetime bestbefore;     public float priceonpackage;}       streamreader reader = new streamreader(system.web.hosting.hostingenvironment.mappath("~/jsondata/prepackjson.json"));     string jsondata = reader.readtoend();     list<prepacklist> listitemsjson = jsonconvert.deserializeobject<list<prepacklist>>(jsondata)  } 

now problem need append list can seriaze agin json file. can help?

unless i'm missing can add item normal , serialize again:

listitemsjson.add(new prepacklist());  var updatedjson = jsonconvert.serializeobject(listitemsjson); 

Comments