Skip to content

Issue with generating types from json payload with special character field names #979

@KCSAbeywickrama

Description

@KCSAbeywickrama

Description

While trying to generate Ballerina types from a valid JSON payload with special character field names, certain field names in the JSON result in invalid Ballerina identifiers.

For example, this part is extracted from a GitHub issue event payload,

{
  "total_count": 0,
  "+1": 0,
  "-1": 0
}

When generating a Ballerina record type, the output looks like this,

type Reactions record {|
    int total_count;
    int +1;
    int -1;
|};

However, +1 and -1 are valid JSON keys, even though they are invalid Ballerina identifiers

Steps to Reproduce

Use the given sample payload

Version

1.2.25080717

Environment Details (with versions)

No response

Metadata

Metadata

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions