Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zenroom
Zenroom
Commits
f76153c5
Commit
f76153c5
authored
May 20, 2022
by
Jaromil
Browse files
zencode array remove table from table
supports removal of a dictionary from an array of dictionaries
parent
210779c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lua/zencode_array.lua
View file @
f76153c5
...
...
@@ -62,6 +62,16 @@ local function _when_remove_array(ele, from)
local
arr
=
have
(
from
)
local
found
=
false
local
newdest
=
{
}
if
luatype
(
obj
)
==
'table'
then
-- overload __eq for tables
local
m_obj
=
{}
local
m_arr
=
{}
setmetatable
(
arr
,
m_arr
)
setmetatable
(
obj
,
m_obj
)
local
fun
=
function
(
l
,
r
)
return
ZEN
.
serialize
(
l
)
==
ZEN
.
serialize
(
r
)
end
m_arr
.
__eq
=
fun
m_obj
.
__eq
=
fun
end
for
k
,
v
in
next
,
arr
,
nil
do
if
not
(
v
==
obj
)
then
table.insert
(
newdest
,
v
)
...
...
test/zencode_array/run.sh
View file @
f76153c5
...
...
@@ -564,4 +564,98 @@ If the elements in 'nested arr' are not all equal
Then print string 'OK'
EOF
cat
<<
EOF
| save array table-arrays.json
{ "identity": {
"announceAPI": "/api/zenswarm-oracle-announce",
"baseUrl": "http://zenswarm.zenroom.org",
"country": "IT",
"ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
"get-identityAPI": "/api/zenswarm-oracle-get-identity",
"http-postAPI": "/api/zenswarm-oracle-http-post",
"oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
"pingAPI": "/api/zenswarm-oracle-ping.zen",
"port_http": "28170",
"port_https": "28331",
"sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
"timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
"tracker": "https://apiroom.net/",
"type": "restroom-mw",
"updateAPI": "/api/zenswarm-oracle-update",
"version": "2"
},
"identities": [
{
"announceAPI": "/api/zenswarm-oracle-announce",
"baseUrl": "http://zenswarm.zenroom.org",
"country": "IT",
"ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
"get-identityAPI": "/api/zenswarm-oracle-get-identity",
"http-postAPI": "/api/zenswarm-oracle-http-post",
"oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
"pingAPI": "/api/zenswarm-oracle-ping.zen",
"port_http": "26962",
"port_https": "25991",
"region": "NONE",
"sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
"timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
"tracker": "https://apiroom.net/",
"type": "restroom-mw",
"updateAPI": "/api/zenswarm-oracle-update",
"version": "2"
},
{
"announceAPI": "/api/zenswarm-oracle-announce",
"baseUrl": "http://zenswarm.zenroom.org",
"country": "IT",
"ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
"get-identityAPI": "/api/zenswarm-oracle-get-identity",
"http-postAPI": "/api/zenswarm-oracle-http-post",
"oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
"pingAPI": "/api/zenswarm-oracle-ping.zen",
"port_http": "26368",
"port_https": "29841",
"region": "NONE",
"sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
"timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
"tracker": "https://apiroom.net/",
"type": "restroom-mw",
"updateAPI": "/api/zenswarm-oracle-update",
"version": "2"
},
{
"announceAPI": "/api/zenswarm-oracle-announce",
"baseUrl": "http://zenswarm.zenroom.org",
"country": "IT",
"ethereum-notarizationAPI": "/api/ethereum-to-ethereum-notarization.chain",
"get-identityAPI": "/api/zenswarm-oracle-get-identity",
"http-postAPI": "/api/zenswarm-oracle-http-post",
"oracle-key-issuance": "/api/zenswarm-oracle-key-issuance.chain",
"pingAPI": "/api/zenswarm-oracle-ping.zen",
"port_http": "28170",
"port_https": "28331",
"sawroom-notarizationAPI": "/api/sawroom-to-ethereum-notarization.chain",
"timestampAPI": "/api/zenswarm-oracle-get-timestamp.zen",
"tracker": "https://apiroom.net/",
"type": "restroom-mw",
"updateAPI": "/api/zenswarm-oracle-update",
"version": "2"
}
]
}
EOF
cat
<<
EOF
| zexe remote-table-from-table.zen -a table-arrays.json | jq .
Given I have a 'string array' named 'identities'
Given I have a 'string array' named 'identity'
When I create the size of 'identities'
and I rename 'size' to 'before'
and I remove the 'identity' from 'identities'
and I create the size of 'identities'
and I rename 'size' to 'after'
Then print the 'before'
and print the 'after'
EOF
success
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment