ballerina-lang icon indicating copy to clipboard operation
ballerina-lang copied to clipboard

Improve JSON to Record Conversion

Open f-schnabel opened this issue 1 year ago • 5 comments
trafficstars

Purpose

I modified both json-mapper and json-to-record-converter (in the Language Server) to have the desired behaviour from the issue. Records are now always closed and might have a rest field with json...;. Also, no any or anydata is produced but only json.

Fixes #42610

Approach

Describe how you are implementing the solutions along with the design details.

Samples

Provide high-level details about the samples related to this feature.

Remarks

List any other known issues, related PRs, TODO items, or any other notes related to the PR.

Check List

  • [x] Read the Contributing Guide
  • [ ] Updated Change Log
  • [ ] Checked Tooling Support (#<Issue Number>)
  • [ ] Added necessary tests
    • [ ] Unit Tests
    • [ ] Spec Conformance Tests
    • [ ] Integration Tests
    • [ ] Ballerina By Example Tests
  • [ ] Increased Test Coverage
  • [ ] Added necessary documentation
    • [ ] API documentation
    • [ ] Module documentation in Module.md files
    • [ ] Ballerina By Examples

f-schnabel avatar Oct 11 '24 00:10 f-schnabel

There is a checkstyle failure as well, shall we check that as well?

AzeemMuzammil avatar Oct 14 '24 07:10 AzeemMuzammil

I was a bit unsure about the open/closeness of the records since in the json-mapper the isClosed is also applied into inner records but in the language server json-to-record-converter this is only applied on the outer most level and all inner records were open. I now adjusted the language server module to be the same as json-mapper since I think this approach makes more sense.

f-schnabel avatar Oct 14 '24 10:10 f-schnabel

Codecov Report

Attention: Patch coverage is 84.11215% with 17 lines in your changes missing coverage. Please review.

Project coverage is 77.55%. Comparing base (68e12c3) to head (66f7b52). Report is 40 commits behind head on master.

Files with missing lines Patch % Lines
...io/ballerina/converters/JsonToRecordConverter.java 82.35% 7 Missing and 5 partials :warning:
...va/io/ballerina/jsonmapper/JsonToRecordMapper.java 84.61% 1 Missing and 3 partials :warning:
...a/io/ballerina/converters/util/ConverterUtils.java 50.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #43482      +/-   ##
============================================
- Coverage     77.55%   77.55%   -0.01%     
+ Complexity    58723    58722       -1     
============================================
  Files          3447     3447              
  Lines        219656   219658       +2     
  Branches      28917    28915       -2     
============================================
+ Hits         170364   170365       +1     
- Misses        39891    39892       +1     
  Partials       9401     9401              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 17 '24 19:10 codecov[bot]

@Shadow-Devil Shall we fix the code conflict please?

gimantha avatar Oct 23 '24 12:10 gimantha

@gimantha code conflicts are fixed and pipeline was successful

f-schnabel avatar Oct 23 '24 21:10 f-schnabel