Skip to content

Commit

Permalink
Handled necesssary conversion between string and JToken in converting…
Browse files Browse the repository at this point in the history
… to and from artifacts for nested content complex properties.
  • Loading branch information
AndyButland committed Jan 11, 2022
1 parent 1a95a60 commit f2e0a55
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ public string ToArtifact(object value, PropertyType propertyType, ICollection<Ar

// pass the value, property type and the dependencies collection to the connector to get a "artifact" value
var innerValue = row.PropertyValues[key];
object parsedValue = propertyValueConnector.ToArtifact(innerValue, innerPropertyType, dependencies);

// connectors are expecting strings, not JTokens
object preparedValue = innerValue is JToken
? innerValue?.ToString()
: innerValue;
object parsedValue = propertyValueConnector.ToArtifact(preparedValue, innerPropertyType, dependencies);

// getting Map image value umb://media/43e7401fb3cd48ceaa421df511ec703c to (nothing) - why?!
_logger.Debug<NestedContentValueConnector>("Mapped {Key} value '{PropertyValue}' to '{ParsedValue}' using {PropertyValueConnectorType} for {PropertyType}.", key, row.PropertyValues[key], parsedValue, propertyValueConnector.GetType(), innerPropertyType.Alias);
Expand Down Expand Up @@ -202,6 +207,11 @@ public object FromArtifact(string value, PropertyType propertyType, object curre
{
row.PropertyValues[key] = convertedValue.ToString();
}
// json strings need to be converted into JTokens
else if (convertedValue is string convertedStringValue && convertedStringValue.DetectIsJson())
{
row.PropertyValues[key] = JToken.Parse(convertedStringValue);
}
else
{
row.PropertyValues[key] = convertedValue;
Expand Down

0 comments on commit f2e0a55

Please sign in to comment.