Skip to content
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

Improve JSON to Record Conversion #43482

Merged
merged 13 commits into from
Oct 28, 2024

Conversation

Shadow-Devil
Copy link
Contributor

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

  • Read the Contributing Guide
  • Updated Change Log
  • Checked Tooling Support (#)
  • 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


TypeDescriptorNode nonAnyDataNode = null;
TypeDescriptorNode nonJSONDataNode = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we follow the standard camelCase?

Suggested change
TypeDescriptorNode nonJSONDataNode = null;
TypeDescriptorNode nonJsonDataNode = null;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will fix that soon

@AzeemMuzammil
Copy link
Member

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

@Shadow-Devil
Copy link
Contributor Author

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.

Copy link

codecov bot commented Oct 17, 2024

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 ⚠️
...va/io/ballerina/jsonmapper/JsonToRecordMapper.java 84.61% 1 Missing and 3 partials ⚠️
...a/io/ballerina/converters/util/ConverterUtils.java 50.00% 1 Missing ⚠️
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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gimantha
Copy link
Contributor

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

# Conflicts:
#	misc/ls-extensions/modules/json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverter.java
@Shadow-Devil
Copy link
Contributor Author

@gimantha code conflicts are fixed and pipeline was successful

@gimantha gimantha merged commit 8ef9be1 into ballerina-platform:master Oct 28, 2024
17 of 18 checks passed
@Shadow-Devil Shadow-Devil deleted the issues/42610 branch October 29, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement]: Improvements to JSON to record conversion
5 participants