-
Notifications
You must be signed in to change notification settings - Fork 758
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement closed record with json rest fields for json-to-record-conv…
…erter
- Loading branch information
1 parent
2356c62
commit 100e4cb
Showing
28 changed files
with
642 additions
and
493 deletions.
There are no files selected for viewing
113 changes: 57 additions & 56 deletions
113
...json-to-record-converter/src/main/java/io/ballerina/converters/JsonToRecordConverter.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
214 changes: 106 additions & 108 deletions
214
...to-record-converter/src/test/java/io/ballerina/converters/JsonToRecordConverterTests.java
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
...extensions/modules/json-to-record-converter/src/test/resources/ballerina/basic_schema.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
type NewRecord record { | ||
type NewRecord record {| | ||
string name; | ||
int id; | ||
boolean bark?; | ||
string breed?; | ||
}; | ||
json...; | ||
|}; | ||
|
8 changes: 4 additions & 4 deletions
8
...xtensions/modules/json-to-record-converter/src/test/resources/ballerina/closed_record.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
...xtensions/modules/json-to-record-converter/src/test/resources/ballerina/nested_object.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
type ColorsItem record { | ||
type ColorsItem record {| | ||
string name; | ||
int id; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type Dimensions record { | ||
type Dimensions record {| | ||
int width; | ||
int height; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecord record { | ||
type NewRecord record {| | ||
string name; | ||
boolean checked; | ||
string id; | ||
ColorsItem[] colors; | ||
Dimensions dimensions; | ||
}; | ||
json...; | ||
|}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 9 additions & 6 deletions
15
...modules/json-to-record-converter/src/test/resources/ballerina/nested_object_type_desc.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
type NewRecord record { | ||
type NewRecord record {| | ||
string name; | ||
boolean checked; | ||
string id; | ||
|
||
record { | ||
record {| | ||
string name; | ||
int id; | ||
}[] colors; | ||
json...; | ||
|}[] colors; | ||
|
||
record { | ||
record {| | ||
int width; | ||
int height; | ||
} dimensions; | ||
}; | ||
json...; | ||
|} dimensions; | ||
json...; | ||
|}; |
10 changes: 6 additions & 4 deletions
10
...xtensions/modules/json-to-record-converter/src/test/resources/ballerina/nested_schema.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
type Dimensions record { | ||
type Dimensions record {| | ||
int width; | ||
int height; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecord record { | ||
type NewRecord record {| | ||
boolean checked; | ||
Dimensions dimensions; | ||
int id; | ||
string name; | ||
}; | ||
json...; | ||
|}; | ||
|
5 changes: 3 additions & 2 deletions
5
...-extensions/modules/json-to-record-converter/src/test/resources/ballerina/null_object.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
type NewRecord record { | ||
type NewRecord record {| | ||
json id; | ||
}; | ||
json...; | ||
|}; |
15 changes: 9 additions & 6 deletions
15
.../ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_1.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
type SportsItem record { | ||
type SportsItem record {| | ||
string question; | ||
string answer; | ||
string[] options; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type MathsItem record { | ||
type MathsItem record {| | ||
string question; | ||
string answer; | ||
string[] options; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecord record { | ||
type NewRecord record {| | ||
SportsItem[] sports; | ||
MathsItem[] maths; | ||
}; | ||
json...; | ||
|}; | ||
|
25 changes: 15 additions & 10 deletions
25
...ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_10.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
type BatterItem record { | ||
type BatterItem record {| | ||
string id; | ||
string 'type; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type Batters record { | ||
type Batters record {| | ||
BatterItem[] batter; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type ToppingItem record { | ||
type ToppingItem record {| | ||
string id; | ||
string 'type; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecord record { | ||
type NewRecord record {| | ||
decimal ppu; | ||
Batters batters; | ||
string name; | ||
string id; | ||
string 'type; | ||
ToppingItem[] topping; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecordList record { | ||
type NewRecordList record {| | ||
NewRecord[] newrecordlist; | ||
}; | ||
json...; | ||
|}; |
25 changes: 15 additions & 10 deletions
25
...ons/modules/json-to-record-converter/src/test/resources/ballerina/sample_10_type_desc.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
type Person record { | ||
type Person record {| | ||
|
||
record { | ||
record {| | ||
decimal ppu; | ||
|
||
record { | ||
record { | ||
record {| | ||
record {| | ||
string id; | ||
string 'type; | ||
}[] batter; | ||
} batters; | ||
json...; | ||
|}[] batter; | ||
json...; | ||
|} batters; | ||
|
||
string name; | ||
string id; | ||
string 'type; | ||
|
||
record { | ||
record {| | ||
string id; | ||
string 'type; | ||
}[] topping; | ||
}[] personlist; | ||
}; | ||
json...; | ||
|}[] topping; | ||
json...; | ||
|}[] personlist; | ||
json...; | ||
|}; |
14 changes: 8 additions & 6 deletions
14
...ons/modules/json-to-record-converter/src/test/resources/ballerina/sample_11_type_desc.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
type NewRecord record { | ||
record { | ||
anydata[] donations; | ||
any subscription; | ||
} contributions; | ||
type NewRecord record {| | ||
record {| | ||
json[] donations; | ||
json subscription; | ||
json...; | ||
|} contributions; | ||
string school; | ||
string name; | ||
int age; | ||
}; | ||
json...; | ||
|}; |
15 changes: 9 additions & 6 deletions
15
.../ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_2.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
type Address record { | ||
type Address record {| | ||
string streetAddress; | ||
string city; | ||
string state; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type PhoneNumbersItem record { | ||
type PhoneNumbersItem record {| | ||
string number; | ||
string 'type; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecord record { | ||
type NewRecord record {| | ||
string firstName; | ||
string lastName; | ||
Address address; | ||
string gender; | ||
int age; | ||
PhoneNumbersItem[] phoneNumbers; | ||
}; | ||
json...; | ||
|}; | ||
|
10 changes: 6 additions & 4 deletions
10
.../ls-extensions/modules/json-to-record-converter/src/test/resources/ballerina/sample_3.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
type NewRecord record { | ||
type NewRecord record {| | ||
string color; | ||
string value; | ||
}; | ||
json...; | ||
|}; | ||
|
||
type NewRecordList record { | ||
type NewRecordList record {| | ||
NewRecord[] newrecordlist; | ||
}; | ||
json...; | ||
|}; |
11 changes: 6 additions & 5 deletions
11
...ions/modules/json-to-record-converter/src/test/resources/ballerina/sample_3_type_desc.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
type Person record { | ||
record { | ||
string color; string value; | ||
}[] personlist; | ||
}; | ||
type Person record {| | ||
record {| | ||
string color; string value; json...; | ||
|}[] personlist; | ||
json...; | ||
|}; |
Oops, something went wrong.