From 46c0d573a522e55a91a5e986c9783530190af1ab Mon Sep 17 00:00:00 2001 From: Michael Hoehn Date: Mon, 8 Jul 2024 16:14:20 -0400 Subject: [PATCH] wrap in brackets only if there's more than one object and remove Join functionality --- File_Adapter/CRUD/Create/CreateJson.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/File_Adapter/CRUD/Create/CreateJson.cs b/File_Adapter/CRUD/Create/CreateJson.cs index 873e2fb..9cbfb19 100644 --- a/File_Adapter/CRUD/Create/CreateJson.cs +++ b/File_Adapter/CRUD/Create/CreateJson.cs @@ -63,6 +63,8 @@ public FSFile CreateJson(FSFile file, PushType pushType, PushConfig pushConfig) bool valueTypesFound = false; + int objCount = 0; + foreach (var obj in content) { if (obj == null) @@ -83,6 +85,7 @@ public FSFile CreateJson(FSFile file, PushType pushType, PushConfig pushConfig) } allLines.Add(obj.ToJson()); + objCount++; } if (valueTypesFound) @@ -93,8 +96,10 @@ public FSFile CreateJson(FSFile file, PushType pushType, PushConfig pushConfig) json = allLines.Aggregate((a, b) => a + "," + Environment.NewLine + b); // Join all between square brackets to make a valid JSON array. - json = String.Join(Environment.NewLine, allLines); - json = "[" + json + "]"; + //json = String.Join(Environment.NewLine, allLines); + + if(objCount > 1) + json = "[" + json + "]"; } else {