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

Support projection options to handle un defined nilable properties #4

Merged
merged 13 commits into from
Apr 3, 2024
Merged
2 changes: 1 addition & 1 deletion ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Ballerina"]
keywords = ["json"]
repository = "https://github.com/ballerina-platform/module-ballerina.jsondata"
license = ["Apache-2.0"]
distribution = "2201.8.4"
distribution = "2201.9.0-20240326-110600-aca0cc0c"

[platform.java17]
graalvmCompatible = true
Expand Down
33 changes: 32 additions & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.8.4"
distribution-version = "2201.9.0-20240326-110600-aca0cc0c"

[[package]]
org = "ballerina"
Expand All @@ -14,6 +14,7 @@ version = "0.1.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"},
{org = "ballerina", name = "test"}
]
modules = [
Expand Down Expand Up @@ -41,6 +42,26 @@ modules = [
{org = "ballerina", packageName = "jballerina.java", moduleName = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.__internal"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
]

[[package]]
org = "ballerina"
name = "lang.array"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.__internal"}
]

[[package]]
org = "ballerina"
name = "lang.error"
Expand All @@ -50,6 +71,12 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "lang.object"
version = "0.0.0"
scope = "testOnly"

[[package]]
org = "ballerina"
name = "lang.value"
Expand All @@ -58,6 +85,9 @@ scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
modules = [
{org = "ballerina", packageName = "lang.value", moduleName = "lang.value"}
]

[[package]]
org = "ballerina"
Expand All @@ -66,6 +96,7 @@ version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.array"},
{org = "ballerina", name = "lang.error"}
]
modules = [
Expand Down
1 change: 1 addition & 0 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def stripBallerinaExtensionVersion(String extVersion) {
apply plugin: 'io.ballerina.plugin'

ballerina {
testCoverageParam = "--code-coverage --coverage-format=xml --includes=io.ballerina.lib.data.*:ballerina.*"
packageOrganization = packageOrg
module = packageName
langVersion = ballerinaLangVersion
Expand Down
16 changes: 10 additions & 6 deletions ballerina/json_api.bal
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/jballerina.java;

# Convert value of type `json` to subtype of `anydata`.
Expand Down Expand Up @@ -56,15 +55,20 @@ public isolated function parseStream(stream<byte[], error?> s, Options options =
#
# + v - Source anydata value
# + return - representation of `v` as value of type json
public isolated function toJson(anydata v)
public isolated function toJson(anydata v)
returns json|Error = @java:Method {'class: "io.ballerina.lib.data.jsondata.json.Native"} external;

# Represent the options that can be used to modify the behaviour of the projection.
#
# + allowDataProjection - enable or disable projection
public type Options record {|
boolean allowDataProjection = true;
|};
# + allowDataProjection - Enable or disable projection.
public type Options record {
record {
# If true, nil values will be considered as optional fields in the projection.
prakanth97 marked this conversation as resolved.
Show resolved Hide resolved
boolean nilAsOptionalField = false;
# If true, absent fields will be considered as nilable types in the projection.
prakanth97 marked this conversation as resolved.
Show resolved Hide resolved
boolean absentAsNilableType = false;
}|false allowDataProjection = {};
};

hasithaa marked this conversation as resolved.
Show resolved Hide resolved
# Represents the error type of the ballerina/data.jsondata module. This error type represents any error that can occur
# during the execution of jsondata APIs.
Expand Down
Loading
Loading