# faketoe

> XML to JSON converter

Latest version **2.1.1** (published 2015-07-08) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install faketoe
pnpm add faketoe
yarn add faketoe
bun add faketoe
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2015-07-08 |
| First published | 2012-12-10 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.30 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eran Hammer |
| Maintainers | hueniverse, nlf, wyatt |
| Keywords | xml, json, conversion |

## Links

- npm: https://www.npmjs.com/package/faketoe
- Repository: https://github.com/hapijs/faketoe
- Homepage: https://github.com/hapijs/faketoe#readme
- Issues: https://github.com/hapijs/faketoe/issues
- npm.io page: https://npm.io/package/faketoe

## Dependencies (1)

- [node-expat](https://npm.io/package/node-expat.md) 2.3.x

## 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

- 2.1.1 (latest) — 2015-07-08
- 2.1.0 — 2015-01-05
- 2.0.2 — 2014-08-18
- 2.0.1 — 2014-08-01
- 2.0.0 — 2014-07-23
- 1.0.0 — 2014-03-12
- 0.1.2 — 2013-12-31
- 0.1.1 — 2013-05-19
- 0.1.0 — 2013-04-12
- 0.0.6 — 2013-04-02
- 0.0.5 — 2013-03-06
- 0.0.4 — 2013-03-05
- 0.0.3 — 2013-02-17
- 0.0.2 — 2013-02-07
- 0.0.1 — 2012-12-10

## README

![faketoe Logo](https://raw.github.com/hapijs/faketoe/master/images/faketoe.png)

XML to JSON converter

[![Build Status](https://secure.travis-ci.org/hapijs/faketoe.png)](http://travis-ci.org/hapijs/faketoe)

Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)

## Description
**faketoe** is a simple Node transformation stream for used to convert an XML stream to a JSON object. It is a thin wrapper around [node-expat](https://github.com/node-xmpp/node-expat) and supports the same interface and events as a node-expat object.

## Usage
```javascript
var Fs = require('fs');
var FakeToe = require('./lib');

var parser = FakeToe.createParser(function (error, result) {
    // `result` is:
    // {
    //     item: {
    //             name: '1',
    //         property: 'a',
    //            child: [
    //             [0] {
    //                     name: '2',
    //                 property: 'a',
    //                    child: [
    //                     [0] {
    //                             name: '3',
    //                         property: 'a'
    //                     },
    //                     [1] {
    //                         name: '4'
    //                     }
    //                 ]
    //             },
    //             [1] {
    //                 name: '5'
    //             }
    //         ],
    //          goblins: {
    //             goblin: [
    //                 [0] {
    //                     type: 'ear'
    //                 },
    //                 [1] {
    //                     type: 'nose'
    //                 },
    //                 [2] {
    //                     type: 'throat'
    //                 }
    //             ]
    //         },
    //                x: {
    //               y: [
    //                 [0] 'a',
    //                 [1] 'b',
    //                 [2] 'c'
    //             ]
    //         },
    //            extra: {
    //             extended: 'yes'
    //         },
    //                z: {
    //             verbose: 'no',
    //               $text: 'a'
    //         }
    //     }
    // }

});

parser.on('text', function (text) {

    console.log('text event: ' + text);
});

parser.on('endElement', function (name) {

    console.log('end element event: ' + name);
});

Fs.createReadStream(__dirname + '/test/test1.xml').pipe(parser);
```

### Methods
####`createParser(callback)`
creates an XML to JSON parser (stream). The `callback` function signature is `function (error, result)` where
- `error` - internal error condition
- `result` - the complete JSON object

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