-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom serialization/deserialization of objects #123
Comments
Thoughts ... interesting idea, but let's unroll it a bit wider.
Naming, I think it can be improved
Design
Deseriazation
data lo_my ref to zcl_blah.
create object lo_my exporting ...
lo_json->to_abap( changing cv_container = lo_my ).
" OR a new method (though ... very tentative ...)
lo_my ?= lo_json->rehydrate( new zcl_blah( ) ).
|
Aside from tracing/debugging, I can't think of a scenario where serializing private attributes makes sense. Do we really need this? |
Could be an elegant way to get json representation of objects. E.g. some FI or SD document and you want to send to external service in json. Or you want to serialize an object (or array of object or ...), send the state to another abap system and rehydrate the objects there. Yet ... this looks a bit far fetched for abap. Anyway it's just my imagination, I don't have such cases. And I would also like to keep ajson simple (it is already not that simple ... ). So I'd be glad to see the real use case too. |
Let me explain what the objective is for me. I'm working on an FHIR server and my idea is to make a class for each resource and some general elements. For example, the Patient resource uses the Identifier element which is typical for multiple resources. So in the Patient structure resource, I just need to set the reference to the identifier object Now, when I serialize the patient resource, it automatically fills the Identifier in the structure I need. |
About the deserialization, I have some doubts about how to do it. There will be static methods in the interface, but it will lose the possibility of redefinition. With an instance method we need to instantiate first the object, and then call the method, but the constructor will need parameters. I like the second option, but a prerequisite for the serializable class will be that the constructor won't have importing parameters. |
ref: #119 (see for code example), @jrodriguez-rc
Creating an issue as it might need some discussion.
The text was updated successfully, but these errors were encountered: