# another-json2xml

> another-json2xml is another JavaScript package for converting json to xml.

Latest version **0.0.2** (published 2020-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install another-json2xml
pnpm add another-json2xml
yarn add another-json2xml
bun add another-json2xml
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-11-29 |
| First published | 2020-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stony Chen |
| Maintainers | stonychen |
| Keywords | soap, json to xml, json 2 xml, json2xml, another-json2xml |

## Links

- npm: https://www.npmjs.com/package/another-json2xml
- Repository: https://github.com/stonychen/another-json2xml
- Homepage: https://github.com/stonychen/another-json2xml#readme
- Issues: https://github.com/stonychen/another-json2xml/issues
- npm.io page: https://npm.io/package/another-json2xml

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.2 (latest) — 2020-11-29

## README

# another-json2xml
 
## What is another-json2xml

another-json2xml is another JavaScript package for converting json to xml.

## Install

``` CMD
npm install another-json2xml --save
```

## Usage

``` Typescript
import { XmlDef } from 'another-json2xml'

const xmlDef = new XmlDef()
xmlDef.method = "GetData"
// anotherSoap.defaultEnt = ""
// anotherSoap.tem = ""
// anotherSoap.methodNs = "m"
// anotherSoap.methodNsUrl = "http://tempurl.org/"
xmlDef.bodyEntities = [
  {
    name: "sessionId",
    object: "XXXXX",
    // ns: "ent2",
    // nsUrl: "http://tempurl.org/"
  },
  {
    name: "requestData",
    // ns: "Foo",
    // nsUrl: "http://schemas.datacontract.org/2004/07/Foo.Entities",
    object: {
      foo: "foo",
      bar: "bar>",
      empty: "",
      tata: null,
      bars: ["bar1", ""],
      numbers: [1, 2],
      booleans: [true, false],
      cars: [
        {
          car: {
            name: "car1",
            brand: "Volkswagen"
          },
        },
        {
          car: {
            name: `car2<>&\"'<>&\"'`,
            brand: "BMW"
          },
        },
      ],
    },
  },
]

const xml = xmlDef.toXML()

console.log(xml)
```


Output

``` XML
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:tem="http://tempurl.org/"
	xmlns:ent="http://schemas.datacontract.org/2004/07/ent.Entities"
	xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays"  >
	<soapenv:Header/>
	<soapenv:Body>
		<tem:GetData >
			<tem:sessionId>XXXXX</tem:sessionId>
			<tem:requestData>
				<ent:foo>foo</ent:foo>
				<ent:bar>bar&gt;</ent:bar>
				<ent:empty/>
				<ent:tata i:nil="true"/>
				<ent:bars>
					<arr:string>bar1</arr:string>
					<arr:string/>
				</ent:bars>
				<ent:numbers>
					<arr:number>1</arr:number>
					<arr:number>2</arr:number>
				</ent:numbers>
				<ent:booleans>
					<arr:boolean>true</arr:boolean>
					<arr:boolean>false</arr:boolean>
				</ent:booleans>
				<ent:cars>
					<ent:car>
						<ent:name>car1</ent:name>
						<ent:brand>Volkswagen</ent:brand>
					</ent:car>
					<ent:car>
						<ent:name>car2&lt;&gt;&amp;&quot;&apos;&lt;&gt;&amp;&quot;&apos;</ent:name>
						<ent:brand>BMW</ent:brand>
					</ent:car>
				</ent:cars>
			</tem:requestData>
		</tem:GetData>
	</soapenv:Body>
</soapenv:Envelope>
```

---
_Source: https://npm.io/package/another-json2xml · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
