@@ -29,22 +29,19 @@ public override string ConvertDbToString(Property property, PropertyType propert
2929 return string . Empty ;
3030
3131 // Process value
32- ConvertDbToStringRecursive ( value , property , propertyType , dataTypeService ) ;
32+ ConvertDbToStringRecursive ( value , dataTypeService ) ;
3333
34- // Update the value on the property
35- property . Value = JsonConvert . SerializeObject ( value ) ;
36-
37- // Pass the call down
38- return base . ConvertDbToString ( property , propertyType , dataTypeService ) ;
34+ // Return the serialized value
35+ return JsonConvert . SerializeObject ( value ) ;
3936 }
4037
41- protected void ConvertDbToStringRecursive ( JToken token , Property property , PropertyType propertyType , IDataTypeService dataTypeService )
38+ protected void ConvertDbToStringRecursive ( JToken token , IDataTypeService dataTypeService )
4239 {
4340 if ( token is JArray jArr )
4441 {
4542 foreach ( var item in jArr )
4643 {
47- ConvertDbToStringRecursive ( item , property , propertyType , dataTypeService ) ;
44+ ConvertDbToStringRecursive ( item , dataTypeService ) ;
4845 }
4946 }
5047
@@ -60,7 +57,7 @@ protected void ConvertDbToStringRecursive(JToken token, Property property, Prope
6057 {
6158 if ( kvp . Value is JArray || kvp . Value is JObject )
6259 {
63- ConvertDbToStringRecursive ( kvp . Value , property , propertyType , dataTypeService ) ;
60+ ConvertDbToStringRecursive ( kvp . Value , dataTypeService ) ;
6461 }
6562 }
6663 }
@@ -82,22 +79,19 @@ public override object ConvertDbToEditor(Property property, PropertyType propert
8279 return string . Empty ;
8380
8481 // Process value
85- ConvertDbToEditorRecursive ( value , property , propertyType , dataTypeService ) ;
82+ ConvertDbToEditorRecursive ( value , dataTypeService ) ;
8683
87- // Update the value on the property
88- property . Value = JsonConvert . SerializeObject ( value ) ;
89-
90- // Pass the call down
91- return base . ConvertDbToEditor ( property , propertyType , dataTypeService ) ;
84+ // Return the JObject, Angular can handle it directly
85+ return value ;
9286 }
9387
94- protected void ConvertDbToEditorRecursive ( JToken token , Property property , PropertyType propertyType , IDataTypeService dataTypeService )
88+ protected void ConvertDbToEditorRecursive ( JToken token , IDataTypeService dataTypeService )
9589 {
9690 if ( token is JArray jArr )
9791 {
9892 foreach ( var item in jArr )
9993 {
100- ConvertDbToEditorRecursive ( item , property , propertyType , dataTypeService ) ;
94+ ConvertDbToEditorRecursive ( item , dataTypeService ) ;
10195 }
10296 }
10397
@@ -113,7 +107,7 @@ protected void ConvertDbToEditorRecursive(JToken token, Property property, Prope
113107 {
114108 if ( kvp . Value is JArray || kvp . Value is JObject )
115109 {
116- ConvertDbToEditorRecursive ( kvp . Value , property , propertyType , dataTypeService ) ;
110+ ConvertDbToEditorRecursive ( kvp . Value , dataTypeService ) ;
117111 }
118112 }
119113 }
@@ -123,27 +117,31 @@ protected void ConvertDbToEditorRecursive(JToken token, Property property, Prope
123117 public override object ConvertEditorToDb ( ContentPropertyData editorValue , object currentValue )
124118 {
125119 // Convert / validate value
126- if ( editorValue . Value == null || string . IsNullOrWhiteSpace ( editorValue . Value . ToString ( ) ) )
127- return null ;
120+ if ( editorValue . Value == null )
121+ return string . Empty ;
128122
129- var value = JsonConvert . DeserializeObject < JToken > ( editorValue . Value . ToString ( ) ) ;
123+ var dbValue = editorValue . Value . ToString ( ) ;
124+ if ( string . IsNullOrWhiteSpace ( dbValue ) )
125+ return string . Empty ;
126+
127+ var value = JsonConvert . DeserializeObject < JToken > ( dbValue ) ;
130128 if ( value == null || ( value is JArray && ( ( JArray ) value ) . Count == 0 ) )
131- return null ;
129+ return string . Empty ;
132130
133131 // Process value
134- ConvertEditorToDbRecursive ( value , editorValue , currentValue ) ;
132+ ConvertEditorToDbRecursive ( value , currentValue ) ;
135133
136134 // Return value
137135 return JsonConvert . SerializeObject ( value ) ;
138136 }
139137
140- protected void ConvertEditorToDbRecursive ( JToken token , ContentPropertyData editorValue , object currentValue )
138+ protected void ConvertEditorToDbRecursive ( JToken token , object currentValue )
141139 {
142140 if ( token is JArray jArr )
143141 {
144142 foreach ( var item in jArr )
145143 {
146- ConvertEditorToDbRecursive ( item , editorValue , currentValue ) ;
144+ ConvertEditorToDbRecursive ( item , currentValue ) ;
147145 }
148146 }
149147
@@ -159,7 +157,7 @@ protected void ConvertEditorToDbRecursive(JToken token, ContentPropertyData edit
159157 {
160158 if ( kvp . Value is JArray || kvp . Value is JObject )
161159 {
162- ConvertEditorToDbRecursive ( kvp . Value , editorValue , currentValue ) ;
160+ ConvertEditorToDbRecursive ( kvp . Value , currentValue ) ;
163161 }
164162 }
165163 }
0 commit comments