Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
prakanth97 committed Apr 3, 2024
2 parents 4e52675 + b0d3dfe commit ee6801c
Show file tree
Hide file tree
Showing 21 changed files with 2,228 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*.zip
*.tar.gz
*.rar
bin

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
Expand Down
23 changes: 21 additions & 2 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ org = "ballerina"
name = "data.jsondata"
version = "0.1.0"
authors = ["Ballerina"]
keywords = ["json"]
repository = "https://github.com/ballerina-platform/module-ballerina.jsondata"
keywords = ["json", "json path", "json-transform", "json transform", "json to json", "json-convert", "json convert"]
repository = "https://github.com/ballerina-platform/module-ballerina-data.jsondata"
license = ["Apache-2.0"]
distribution = "2201.9.0-20240326-110600-aca0cc0c"
export = ["data.jsondata"]

[platform.java17]
graalvmCompatible = true
Expand All @@ -16,3 +17,21 @@ groupId = "io.ballerina.lib"
artifactId = "jsondata-native"
version = "0.1.0"
path = "../native/build/libs/data.jsondata-native-0.1.0-SNAPSHOT.jar"

[[platform.java17.dependency]]
path = "./lib/json-path-2.9.0.jar"
groupId = "com.jayway.jsonpath"
artifactId = "json-path"
version = "2.9.0"

[[platform.java17.dependency]]
path = "./lib/json-smart-2.4.7.jar"
groupId = "net.minidev.json"
artifactId = "json-smart"
version = "2.4.7"

[[platform.java17.dependency]]
path = "./lib/accessors-smart-2.4.7.jar"
groupId = "net.minidev.json"
artifactId = "accessors-smart"
version = "2.4.7"
33 changes: 32 additions & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ version = "0.1.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.float"},
{org = "ballerina", name = "lang.int"},
{org = "ballerina", name = "lang.object"},
{org = "ballerina", name = "lang.value"},
{org = "ballerina", name = "test"}
]
Expand Down Expand Up @@ -73,9 +76,37 @@ dependencies = [

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

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

[[package]]
org = "ballerina"
name = "lang.object"
version = "0.0.0"
modules = [
{org = "ballerina", packageName = "lang.object", moduleName = "lang.object"}
]

[[package]]
org = "ballerina"
Expand Down
20 changes: 20 additions & 0 deletions ballerina/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,30 @@ ballerina {
langVersion = ballerinaLangVersion
}

configurations {
externalJars
}

dependencies {

externalJars(group: 'com.jayway.jsonpath', name: 'json-path', version: "${javaJsonPathVersion}") {
transitive = false
}
externalJars(group: 'net.minidev', name: 'json-smart', version: "${javaJsonSmartVersion}") {
transitive = false
}
externalJars(group: 'net.minidev', name: 'accessors-smart', version: "${javaAccessorsSmartVersion}") {
transitive = false
}
}

task updateTomlFiles {
doLast {
def newConfig = ballerinaTomlFilePlaceHolder.text.replace("@project.version@", project.version)
newConfig = newConfig.replace("@toml.version@", tomlVersion)
newConfig = newConfig.replace("@jsonpath.version@", project.javaJsonPathVersion)
newConfig = newConfig.replace("@jsonsmart.version@", project.javaJsonSmartVersion)
newConfig = newConfig.replace("@accessors.version@", project.javaAccessorsSmartVersion)
ballerinaTomlFile.text = newConfig

def newCompilerPluginToml = compilerPluginTomlFilePlaceHolder.text.replace("@project.version@", project.version)
Expand Down
19 changes: 19 additions & 0 deletions ballerina/errors.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

# 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.
public type Error distinct error;
2 changes: 1 addition & 1 deletion ballerina/init.bal
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ isolated function init() {
}

isolated function setModule() = @java:Method {
'class: "io.ballerina.lib.data.jsondata.utils.ModuleUtils"
'class: "io.ballerina.lib.data.ModuleUtils"
} external;
4 changes: 0 additions & 4 deletions ballerina/json_api.bal
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ public type Options record {
}|false allowDataProjection = {};
};

# 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.
public type Error distinct error;

# Defines the name of the JSON Object key.
#
# + value - The name of the JSON Object key
Expand Down
56 changes: 56 additions & 0 deletions ballerina/read.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
//
// WSO2 LLC. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/jballerina.java;
import ballerina/lang.'object as obj;

public type JsonPathValue json;

public type JsonPathRawTemplate object {
*obj:RawTemplate;
public string[] & readonly strings;
public JsonPathValue[] insertions;
};

# Extract details from the given JSON value using the provided query template expression.
#
# ```ballerina
# read({id: 1, "name": "John Doe"}, `$.name`) => "John Doe"
# ```
#
# + 'json - JSON value
# + query - JSON path expression
# + return - extracted details as JSON value, a jsonpath:Error otherwise
public isolated function read(json 'json, JsonPathRawTemplate query) returns json|Error {
return readJson('json, new JsonPathRawTemplateImpl(query));
}

class JsonPathRawTemplateImpl {
*JsonPathRawTemplate;

isolated function init(JsonPathRawTemplate jsonPathRawTemplate) {
self.strings = jsonPathRawTemplate.strings;
self.insertions = jsonPathRawTemplate.insertions;
}
}

# Extract details from the given JSON value using the provided query expression.
# + 'json - JSON value
# + query - JSON path expression
# + return - extracted details as JSON value, a jsonpath:Error otherwise
isolated function readJson(json 'json, JsonPathRawTemplateImpl query) returns json|Error = @java:Method {
'class: "io.ballerina.lib.data.jsonpath.BJsonPath"
} external;
Loading

0 comments on commit ee6801c

Please sign in to comment.