-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
kong decode json empty array to empty object? #3166
Comments
The request body have empty object and empty list is common. |
Hi, I have investigated this and it is as you say: in order to fix this problem we need the latest cjson, which is not even included in openresty yet, as pointed in openresty/lua-cjson#33 I will leave this issue open but for now there's little we can do. |
@kikito thank you. Now I have compiled it to replace the old cjson.so. |
This seems related to #2309 which I was bit by today. I ended up updating my client code as described in #2309 (comment). Unfortunately doesn't look like this issue has the same type of work around. also see #1208 |
I see OpenResty incorporated the fix: I don't think this is harmless, as the client expects [] and gets {} instead. Any ETA on this issue? Thanks |
We will base our |
I can reproduce this issue with |
Now that our underlying OpenResty version has the fix, we need to actually use it, which means updating the plugin. Our new Admin API already makes use of it along with a few plugins that received contributions to make use of the fix. |
@thibaultcha I suspected this but didn't actually look into it. Thanks for the quick response here! |
Is this solved in the new DAO? |
So, the new DAO returns an empty list for or an explicit null, based on the default: {
"config": {
"blacklist": null,
"hide_groups_header": false,
"whitelist": [
"foo"
]
},
"consumer": null,
"created_at": 1547255075,
"enabled": true,
"id": "a43ddcb0-6559-4ed1-bab9-cda909c4584b",
"name": "acl",
"route": null,
"run_on": "first",
"service": null
} {
"config": {
"add": {
"body": [],
"headers": [
"fp:bar"
],
"querystring": []
},
"append": {
"body": [],
"headers": [],
"querystring": []
},
"http_method": null,
"remove": {
"body": [],
"headers": [],
"querystring": []
},
"rename": {
"body": [],
"headers": [],
"querystring": []
},
"replace": {
"body": [],
"headers": [],
"querystring": []
}
} |
Summary
I want to change the body proxy kong. So I use the plugin
response-transformer
.But kong decode json empty array to empty object.Steps To Reproduce
the
list
is empty array. it should be[]
,but the result is{}
.The dkjson can do it. The master branch of
openresty/cjson
can do it too.It has the methoddecode_array_with_array_mt
. But kong bundle openresty/1.11.2.4. So I only install the master cjson to replace the current cjson.Kong can resolve it the next version.May be the latest version is 1.13.6.1 also hasn't the method.
attempt to call field 'decode_array_with_array_mt' (a nil value)? openresty/lua-cjson#33
Additional Details & Logs
The text was updated successfully, but these errors were encountered: