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

how to convert this code in python lang. #72

Open
Ayush-397 opened this issue Apr 26, 2022 · 0 comments
Open

how to convert this code in python lang. #72

Ayush-397 opened this issue Apr 26, 2022 · 0 comments

Comments

@Ayush-397
Copy link

arr1 = [{
"phone": "123",
"status": "ON",
"id": "id1"
}, {
"phone": "1234",
"status": "ON",
"id": "id1"
}, {
"phone": "1235",
"status": "ON",
"id": "id1"
}]

arr2 = [{
"phone": 123,
"status": "ON",
"id": "id1"
}, {
"phone": "1234",
"status": "ON",
"id": "id1"
}, {
"phone": "1235",
"status": "ON",
"id": "id1"
}]

expression = "$arr1_phone == $arr2_phone";

example

dic = {
"arr1_phone": "123",
"arr1_stratus": "ON",
"arr1_id": "id1",
"arr2_phone": "123",
"arr2_stratus": "ON",
"arr2_id": "id1",
}

finalArray = [];
for (int i=0; i<arr1.length; i++){
for (int j=0; j< arr2.length; j++){
keys = arr1.keys();
dictionary;
for (k=0;k< keys.length;k++){
dictionary["arr1_"+keys[k]] = arr1[i][keys[k]]
}

var keys2 = arr2.keys();
for (k=0;k< keys.length;k++){
dictionary["arr2_"+keys2[k]] = arr1[i][keys2[k]]
}

var result = parser.parse(expression).evaluate(dictionary)

if (result) {
finalArray.push(arr1);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant