test: json plugin with index

This commit is contained in:
vdutta 2021-11-11 17:16:45 +05:30
parent 7bc286f7e1
commit 1b4c5f9d1e
4 changed files with 103 additions and 0 deletions

View file

@ -0,0 +1,69 @@
{
"Device.PD2.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": true,
"mapping": {
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
},
"Device.PD2.{i}.MiniHub.{i}.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": true,
"mapping": {
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "list",
"args": {},
"key": "devices"
}
},
"Device.PD2.{i}.MiniHub.{i}.DeviceInfo.": {
"type": "object",
"protocols": [
"cwmp",
"usp"
],
"access": false,
"array": false,
"Description": {
"type": "string",
"read": true,
"write": false,
"protocols": [
"cwmp",
"usp"
],
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "proxd",
"method": "get",
"args": {
"path": "Device.ProxiedDevice.{i}.MiniHub.{i}.DeviceInfo.Description"
},
"key": "Description"
}
}
]
}
}
}
}
}

View file

@ -0,0 +1,6 @@
{
"devices": [
{ "name": "one"},
{"name": "two"}
]
}

View file

@ -0,0 +1,3 @@
{
"Description": "Test Description"
}

View file

@ -0,0 +1,25 @@
#!/bin/sh
. /usr/share/libubox/jshn.sh
case "$1" in
list)
echo '{ "list" : {}, "get": {"path":"str"}}'
;;
call)
case "$2" in
list)
cat /tmp/proxd.data 2>/dev/null
;;
get)
read input;
json_load "$input"
json_get_var path path
json_init
json_add_string "Description" "$path"
json_dump >/dev/console
json_dump
;;
esac
;;
esac