U4-7382 - Text Properties Containing JSON Are Corrupted on Publish

Created by Nicholas Westby 11 Nov 2015, 02:40:22 Updated by Shannon Deminick 10 Oct 2017, 02:22:09

Tags: Unscheduled

Is duplicated by: U4-9286

Relates to: U4-10067

Subtask of: U4-9609

If you have a property of type "textstring" or "textbox multiple", and you enter some JSON into it, then you publish, you will get [object Object] in its place:


My theory is that this is related to a function, ConvertItemsToJsonIfDetected, on the server side that does some conversion if it thinks a value looks like JSON: https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Core/PropertyEditors/PreValueEditor.cs#L181

My clumsy workaround was to type parentheses instead of curly braces (the code then has to convert the parentheses back to curly braces). That would obviously be harder for JSON containing values that have curly braces or parentheses.

1 Attachments


Geoff Beaumont 22 Sep 2016, 10:38:57

This also seems to affect importing data via CMSImport (https://our.umbraco.org/projects/developer-tools/cmsimport/bugs/80192-json-string-converted-to-object-object).

Anything entered in a text field (Textbox or Textarea) should be left alone and not manipulated in any way!

Geoff Beaumont 22 Jun 2017, 10:30:40

I've just run into this one yet again - I need to allow JSON content to be pasted into a textbox. A very simple operation on every other platform I work with...but not on Umbraco, which still wipes the data out when saving. It's not even like it does anything useful with it - just wipes it out and replaces it with [object Object].

I realise automatically converting to JSON is useful in some parts of the system - but it should be limited to only those areas and not affect the stored data (at the very least, not in this destructive way - it's not even serializing it back to text properly).

A significant data integrity issue, with (at the current count) 26 votes - but no action after 19 months!

Nicholas Westby 26 Jun 2017, 15:32:29

On a related note, it seems a very similar thing happens with dates (i.e., text values that look like dates get reformatted): https://our.umbraco.org/forum/using-umbraco-and-getting-started/86575-date-string-in-text-field-being-reformatted

Robert Copilau 10 Aug 2017, 12:23:09


Nicholas Westby 10 Aug 2017, 15:18:28

@robertcopilau That seems like an odd place to put the code to handle this. Why not handle it closer to where the issue is happening (i.e., where the JSON detection is happening)? One solution I'm imagining would be to allow for property editors to opt out of this JSON detection process. I'm sure there are some other straightforward solutions too; would just need to dig in a bit and figure out exactly what's causing the issue rather than sidestepping it.

Shannon Deminick 11 Aug 2017, 04:57:34

The underlying culprit is PropertyValueEditor.ConvertDbToEditor which does a default check for anything text to try to convert to json. This is where the magic happens for many property editors but of course property editors that do not store json shouldn't have this happening. IIRC when this was implemented (7.0.0 = a long time ago) the decision was made to make it as simple as possible to use and consume json editors and to create property editors and thus anything detected is automagically tried to be converted. In this case both the TextBoxPropertyEditor and the TextAreaPropertyEditor use the default/generic PropertyValueEditor implementation.

Here's the process that happens:

  • The textbox value is submitted as a string like ""
  • The validation, binding, mapping, etc... all takes place correctly and this value will be persisted to the databaes
  • In ContentController.PostSaveInternal we need to re-create the display model from the persisted values in case any event changed the underlying db data and in this we call: Mapper.Map<IContent, ContentItemDisplay>(contentItem.PersistedContent); The mapping logic for this is quite large because there's a lot going on. We end up in the TabsAndPropertiesResolver and then into the ContentPropertyBasicConverter<T> which calls into the associated property editor value converter: Value = editor.ValueEditor.ConvertDbToEditor(property, property.PropertyType, DataTypeService.Value)
  • This does the json detection stuff and voila ... the resulting bound value that is displayed is [object Object] since that is how js deals with it

To fix this the textbox and textarea property editors should use their own implementations of PropertyValueEditor to make sure this underlying json logic doesn't execute.

I'll post a PR in a sec.

Shannon Deminick 11 Aug 2017, 05:13:00

PR: https://github.com/umbraco/Umbraco-CMS/pull/2123

To test, try saving json values to both the textbox and textarea property editors.

Claus Jensen 17 Aug 2017, 08:44:40

Code checks out - it works for json - merged in.

Tom 10 Oct 2017, 00:40:43


I also just noticed this issue when trying to use the multivalues view for a grid setting (as seen here: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/grid-layout/settings-and-styles).

The config value is coming through as [object Object] if I try to access it in my code. I was wondering if the issue has also been fixed for this case. By the way, I am on a self-hosted Umbraco version 7.5.11.

Shannon Deminick 10 Oct 2017, 02:22:09

If you have steps to replicate with the latest version of Umbraco please create a new issue

Priority: Normal

Type: Bug

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.3.1, 7.4.3, 7.5.3, 7.5.4

Due in version: 7.6.6

Sprint: Sprint 65

Story Points: