[MDSAL-39] Provide utility service which will convert Java Generated DTO to JSON Created: 14/Jul/14 Updated: 09/Jan/24 |
|
| Status: | Confirmed |
| Project: | mdsal |
| Component/s: | Binding API, Binding runtime |
| Affects Version/s: | None |
| Fix Version/s: | 14.0.0, 13.0.1 |
| Type: | New Feature | ||
| Reporter: | Tony Tkacik | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | pick-next, pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: Windows |
||
| Description |
|
See comments below for some amount of guidance. As a first cut, we want to transcode information based on InstanceIdentifier + DataObject. The implementation needs to use mdsal-binding-dom-codec-api facilities to transcode the DataObject to a NormalizedNode and then turn that into a JSON string. Once we have a prototype we can then evolve it to more effecient transcoding, including stream setup pipelines. |
| Comments |
| Comment by Tony Tkacik [ 16/Jul/14 ] |
|
What you want to do is implement an service with signature JSONCodec extends BindingCodec<String,DataObject> { String serialize(DataObject); Which will: So basicly your service is integration of two services: BindingIndependentMappingService is available via Config subsystem and OSGI registry, but not directly via MD-SAL. |
| Comment by Tony Tkacik [ 17/Jul/14 ] |
|
DOM to XML is converted using XMLDocumentUtils and same utility functions |
| Comment by Mina [ 10/Aug/14 ] |
|
(In reply to Tony Tkacik from comment #1) > The following service: should be implemented getting idea from XMLDocumentUtils. And also JsonCodec has the following two parts when serializes:
public class JSONCodec implements BindingCodec<String,DataObject> { private BindingIndependentMappingService mappingService; public String serialize(DataObject dataObject) { CompositeNode node = mappingService.toDataDom(dataObject); ..... }public DataObject deserialize(String str) { ..... } |
| Comment by Mina [ 10/Aug/14 ] |
|
(In reply to Mina Aslani from comment #3) > > > Is this how suggested for the bug to be fixed? |
| Comment by Robert Varga [ 24/Jul/21 ] |
|
Yes, although the IO part of it should provide integration with IO, i.e. write to OutputStream, etc. |