You are not serializing a list of 3 DeskObjects - Your JSON suggests that you are serializing a list of 1 DeskObject three times.
I used something close to your code in this code. Without seeing your full serialization/object creation code, I can't tell what's going on exactly. But it looks like you are serializing one DeskObject in your comment above and not a list of 3 DeskObjects.
In my example, I instantiate 3 DeskObjects inline in a list like so:
List<DeskObject> list = new List<DeskObject>() { new DeskObject(){...}, new DeskObject(){...}, new DeskObject(){...} } ;
You could also create your DeskObjects and get them into the list provided they were already created previously:
list.Add(myDeskObject1);
list.Add(myDeskObject2);
list.Add(myDeskObject3);
Then, after the list is completely full:
var serializer = new JsonSerializer();
using (StreamWriter file = new StreamWriter(@"quotes.json", false))
{ serializer.Serialize(file, list); }
This results in the following JSON:
[
{
"CurrentDate": "09 Feb 2018",
"CustomerName": "Jonathan Smith",
"Width": 43,
"Depth": 43,
"numOfDrawers": 1,
"surfMaterial": "Oak",
"RushOrderDays": 3,
"TotalQuote": 1339
},
{
"CurrentDate": "09 Feb 2018",
"CustomerName": "Tim Taylor",
"Width": 24,
"Depth": 44,
"numOfDrawers": 3,
"surfMaterial": "Laminate",
"RushOrderDays": 5,
"TotalQuote": 556
},
{
"CurrentDate": "09 Feb 2018",
"CustomerName": "Cindy Crawford",
"Width": 24,
"Depth": 24,
"numOfDrawers": 5,
"surfMaterial": "Pine",
"RushOrderDays": 5,
"TotalQuote": 570
}
]
Which correctly parses into a list of 3 DeskObjects. The only way I could manage to get JSON like yours into the file was to use this code.
tl;dr make sure you fill your list before serializing it.
Edit:
Reviewing your code, this is your issue.
var deskObjects = new List<Desk.DeskObject>();
deskObjects.Add(deskObject);
var result = JsonConvert.SerializeObject(deskObject, Formatting.Indented);
File.AppendAllText(@"quotes.json", result);
You are creating a new List every time you have a new quote, and serializing it, then appending that to file. This means you are appending '[{item}]' to a file that contains [{item1}][{item2}], etc.
Instead you need to read the List of DeskObjects out of the JSON first, so that you actually have a C# collection. Then add the current DeskObject to it. Finally, rewrite the entire file again (do not append) by serializing the new list.
I am trying to direct you there without writing the code for you - it's important that you understand the concept that when you call AppendAllText, you are not inserting something into a JSON tree. You are just appending raw text to the end of a file containing raw text.