Skip to content

Commit 0a94159

Browse files
author
Claus
committed
Merge branch 'elglogins-master' into dev
2 parents 6583246 + f5ddd38 commit 0a94159

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/NestedContentValueConnector.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ public string GetValue(Property property, ICollection<ArtifactDependency> depend
5757
if (value.DetectIsJson() == false)
5858
return null;
5959

60-
var nestedContent = JsonConvert.DeserializeObject<NestedContentValue[]>(value);
60+
var nestedContent = new List<NestedContentValue>();
61+
if (value.Trim().StartsWith("{"))
62+
nestedContent.Add(JsonConvert.DeserializeObject<NestedContentValue>(value));
63+
else
64+
nestedContent.AddRange(JsonConvert.DeserializeObject<NestedContentValue[]>(value));
6165

62-
if (nestedContent == null)
66+
if (nestedContent.All(x => x == null))
6367
return null;
6468

6569
var allContentTypes = nestedContent.Select(x => x.ContentTypeAlias)
@@ -243,7 +247,11 @@ public void SetValue(IContentBase content, string alias, string value)
243247
}
244248

245249
// NestedContent does not use formatting when serializing JSON values
246-
value = JArray.FromObject(nestedContent).ToString(Formatting.None);
250+
if (nestedContent.Length == 1)
251+
value = JObject.FromObject(nestedContent.FirstOrDefault()).ToString(Formatting.None);
252+
else
253+
value = JArray.FromObject(nestedContent).ToString(Formatting.None);
254+
247255
content.SetValue(alias, value);
248256
}
249257

0 commit comments

Comments
 (0)