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

[Bug]: JSON To Record generation fails when a JSON object with recurring field name is given #40280

Closed
AzeemMuzammil opened this issue Apr 23, 2023 · 3 comments · Fixed by #40320, #41113 or #41143
Assignees
Labels
Area/JSONToRecordConverter JSON to Ballerina record conversion tool related issues Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Bug
Milestone

Comments

@AzeemMuzammil
Copy link
Member

Description

JSON To Record generation fails to generate a Ballerina record when the provided JSON object has a field name that is recurring.

Example:

{
    "bar": {
        "foo": "Foo Text",
        "bar": "Bar Text"
    }
}

the above JSON will produce a Record like the below,

type Bar record {
    string foo;
    string bar;
};

type NewRecord record {
    Bar bar;
};

But,

{
    "bar": {
        "foo": "Foo Text",
        "bar": {
            "baz": "Baz Text"
        }
    }
}

the above JSON fails to produce any Ballerina record.

The reason for that is bar is a JSON object and it has another child object with the same field name bar.
But the above JSON should produce a record like the one below.

type Bar record {
    string foo?;
    Bar bar?;
    string baz?;
};

type NewRecord record {
    Bar bar;
};

Steps to Reproduce

No response

Affected Version(s)

No response

OS, DB, other environment details and versions

No response

Related area

-> Other Area

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@AzeemMuzammil AzeemMuzammil added Type/Bug Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Area/JSONToRecordConverter JSON to Ballerina record conversion tool related issues labels Apr 23, 2023
@AzeemMuzammil AzeemMuzammil self-assigned this Apr 23, 2023
@github-actions
Copy link

github-actions bot commented Jul 6, 2023

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

@AzeemMuzammil
Copy link
Member Author

Reopening this issue as this issue still persists with recurring field names when those fields are arrays,

@github-actions
Copy link

github-actions bot commented Aug 1, 2023

This issue is NOT closed with a proper Reason/ label. Make sure to add proper reason label before closing. Please add or leave a comment with the proper reason label now.

      - Reason/EngineeringMistake - The issue occurred due to a mistake made in the past.
      - Reason/Regression - The issue has introduced a regression.
      - Reason/MultipleComponentInteraction - Issue occured due to interactions in multiple components.
      - Reason/Complex - Issue occurred due to complex scenario.
      - Reason/Invalid - Issue is invalid.
      - Reason/Other - None of the above cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment