Try our conversational search powered by Generative AI!

How to properly implement JSON PropertyData?

Vote:
 

Hi,

I'm trying to implement a custom PropertyDefinitionTypePlugIn for JSON data with the following spec.

  1. The serialized JSON needs to be stored in the LongString column in the database.
  2. The object that will be serialized/deserialized has a ContentReference property (among others).
  3. IReferenceMap should be implemented to support import/export.

I'm finding this quite hard to implement though because of issues with "Lazy loaded property value is not supported by the current property instance" when serialized string is more than 255 characters.

How are we supposed to properly implement ILazyProperty? First of all, it's in an internal namespace and I can't find any documentation. And when looking at PropertyLongString implementation there is a load of internal code.

I really don't want to create a messy implementation that inherits from PropertyLongString with overrides and inline serializing/deserializing. I have done this before, but have never felt good about it so I thought that I will ask this time to see if I'm missing something. It's too complicated to do this basic thing. :)

#282987
Edited, Jul 04, 2022 11:39
Vote:
 

Hi Mattias,

I want to learn more about the ILazyProperty myself actually. Any chance you could post your new type so I can have a play?

#283270
Jul 06, 2022 13:37
Vote:
 

Hi Mattias,

The lazy loading error can be also caused by duplicate property definitions in the database — which can happen when you update the namespace in your property class for example. I wrote this article about the error for version 11 of the CMS. It might not help you with your 255 limit problem, but I recommend keeping tabs of your property definition in the database.
(Property definition editing view has been removed from the CMS in version 12?)

Note that there is the PropertyJson class that you can try to inherit from instead of PropertyLongString. I did some digging and it looks like this stores the JSON as a LongString in the database. The PropertyJsonTransform and JsonPropertyValueConverter classes handle the serialization and what not. Then there are also these internal classes: ContentReferenceDatabaseJsonConverter & DefaultPropertyJson

Hope this helps 😃

#283547
Jul 12, 2022 1:06
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.