Hybrid serialization
 

Hybrid serialization

2 posts, 0 answered
  1. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    18 Jan 2019
    Link to this post
    We have following class:
    using be.cce.SmartTools.Query.FetchDataCustomParameter.
    using Consultingwerk.NativeJsonSerializable from propath.
    using Consultingwerk.JsonSerializable from propath.
    using be.cce.SmartTools.base.FetchCmpIdParameter from propath.
    using Progress.Json.ObjectModel.JsonObject from propath.

    block-level on error undo, throw.

    class be.cce.SmartTools.SmartFramework.BusinessMethodParameter serializable
        inherits NativeJsonSerializable:

        define public serializable property MethodParameters as JsonObject no-undo
            get.
            set.

        define public serializable property FetchCmpIdParameter as FetchCmpIdParameter no-undo
            get.
            set.

        define public non-serializable property MethodParameterObject as JsonSerializable no-undo
            get.
            set.

    end class.
    The MethodParameterObject is JsonSerializable, but not native serializable as specific code is needed. It is in fact a class that inherits from ListQueryExpression and that implements JsonSerializable (as not the whole hierarchy of ListQueryExpression is serializable).
    As far as we know there is no way to get event-like places to add custom serialization.
    Then we tried following approach:
        define public serializable property MethodParameterObjectSerialized as longchar no-undo  
            get:                                                                              
                                                                                              
                if valid-object(MethodParameterObject )                                           
                then return MethodParameterObject :Serialize().                                   
                else return "".                                                               
            end get.                                                                          
            set (input iSerialized as longchar):                                              
                define variable lCustomListQueryExpression as CustomListQueryExpression no-undo.
                                                                                              
                lCustomListQueryExpression = new CustomListQueryExpression ().                   
                lCustomListQueryExpression:Deserialize(iSerialized).                           
                                                                                              
                MethodParameterObject = lFetchDataCustomParameter.                               
                                                                                              
            end set.      
    We were hoping (but knew better) that the getter and setter code would be used during the native serialization, but that doesn't seem to be the case.
    So the only approach that's left is to do the serialization/deserialization at specific places in the code where this parameter object is being passed along.

    Are we missing something here or does someone see another approach to accomplish this?
    .

    Last modified on 18 Jan 2019 16:01 by Bert Strobbe
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    19 Jan 2019 in reply to Bert Strobbe
    Link to this post
    Hi Bert,

    with regards to the question with the Progress Native Serialization, you should discuss that on Progress communities. But I think the answer is simply no. The native serialization bypasses get'ters and set'ters - which is probably part of the performance advantage.

    My recommendation would be to implement the whole thing based on our serialization - because we are more flexible. 

    Another option might be to use Progress' deserialization and then call a "PostDeserialize" method in the new object instance to post-process the deserialization result. 

    Regards,
    Mike
2 posts, 0 answered