An open API service indexing awesome lists of open source software.

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

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)