https://github.com/tuananh/kong-plugin-xml-json-transformer
An experimental XML to JSON (and vice-versa) transformer plugin for Kong
https://github.com/tuananh/kong-plugin-xml-json-transformer
json kong-plugin xml
Last synced: about 2 months ago
JSON representation
An experimental XML to JSON (and vice-versa) transformer plugin for Kong
- Host: GitHub
- URL: https://github.com/tuananh/kong-plugin-xml-json-transformer
- Owner: tuananh
- License: mit
- Created: 2023-12-05T02:44:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-08T02:19:57.000Z (over 2 years ago)
- Last Synced: 2025-01-24T16:28:52.476Z (over 1 year ago)
- Topics: json, kong-plugin, xml
- Language: Lua
- Homepage:
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kong-plugin-xml-json-transformer
An experimental XML to JSON (and vice-versa) transformer plugin for Kong.
This repo include 2 plugins:
- `xml-json-transformer` at `./kong/plugins/xml-json-transformer`
- `json-xml-transformer` at `./kong/plugins/json-xml-transformer`
## Testing
Start Kong instance along with the plugin.
```sh
$ docker compose up
```
This will launch:
- A nginx instance with `./nginx-www` mounted to `/usr/share/nginx/html`. We will use this as test upstream for Kong.
- A Kong instance in dbless mode. The configuration is loaded from `kong/kong.yml`.
- The declarative configuration setup a single service for testing.
Test the route to see if the plugin is working properly. For example, let's try XML to JSON trasnformer
```sh
$ curl --silent http://localhost:8000/xml/medium.xml | jq
```
Expected output
```json
{
"slideshow": {
"_attr": {
"date": "Date of publication",
"author": "Yours Truly",
"title": "Sample Slide Show"
},
"slide": [
{
"_attr": {
"type": "all"
},
"title": "Wake up to WonderWidgets!"
},
{
"_attr": {
"type": "all"
},
"item": [
{
"1": "Why",
"2": "are great",
"em": "WonderWidgets"
},
{},
{
"1": "Who",
"2": "WonderWidgets",
"em": "buys"
}
],
"title": "Overview"
}
]
}
}
```
Or JSON to XML transformer:
```sh
$ curl --silent http://localhost:8000/json/medium.json
```
Expected output in XML
```xml
Wake up to WonderWidgets!
<2>are great2>
<1>Why1>
WonderWidgets
<2>WonderWidgets2>
<1>Who1>
buys
Overview
```
## License
[MIT](./LICENSE)