gucbi
How to encapsulate the code that has been processed using the Newtonsoft Json library?
I used the Newtonsoft Json library to write data to a JSON file, but I don't know how to encapsulate this part of the code. How to encapsulate it?
#######
JObject ArchiveBaseInfo = new JObject(
new JProperty("Version", ArchiveVersion),
new JProperty("Name", EncodeName),
new JProperty("ID", PlayerID)
);
File.WriteAllText(ArchiveFile, ArchiveBaseInfo.ToString());
// write JSON directly to a file
using (StreamWriter file = File.CreateText(ArchiveFile))
using (JsonTextWriter writer = new JsonTextWriter(file))
{
ArchiveBaseInfo.WriteTo(writer);
}
7 replies