{"name":"camaro","version":"3.0.19","description":"Transforming XML to JSON using Node.js binding to native pugixml parser library","homepage":"https://github.com/tuananh/camaro","bugs":{"url":"https://github.com/tuananh/camaro/issues"},"main":"index.js","typings":"index.d.ts","scripts":{"test":"istanbul test ./node_modules/tape/bin/tape test/*.test.js","cover":"istanbul cover ./node_modules/tape/bin/tape test/*.test.js","bench":"node benchmark","install":"node-pre-gyp install --fallback-to-build"},"repository":{"type":"git","url":"git+https://github.com/tuananh/camaro.git"},"keywords":["xpath","json","transform","pugixml","xml","parser","n-api","xml2json"],"author":{"name":"Tuan Anh Tran","email":"me@tuananh.org","url":"https://tuananh.org"},"license":"MIT","dependencies":{"node-addon-api":"2.0.0","node-pre-gyp":"0.14.0"},"devDependencies":{"istanbul":"0.4.5","tape":"4.12.0"},"binary":{"module_name":"camaro","module_path":"./lib/binding/","host":"https://github.com/tuananh/camaro/releases/download/","remote_path":"{version}"},"bundleDependencies":["node-pre-gyp"],"readme":"# camaro\n\n[![NPM](https://nodei.co/npm/camaro.png?downloads=true)](https://npmjs.org/package/camaro)\n\n> camaro is an utility to transform XML to JSON, using Node.js binding to native XML parser [pugixml](http://pugixml.org/), one of the fastest XML parser around.\n\n[![npm](https://badgen.net/npm/v/camaro)](https://npm.im/camaro)\n[![Travis](https://badgen.net/travis/tuananh/camaro/master)](https://travis-ci.org/tuananh/camaro)\n[![AppVeyor](https://badgen.net/appveyor/ci/tuananh/camaro/master)](https://ci.appveyor.com/project/tuananh/camaro)\n[![TypeScript definitions on DefinitelyTyped](https://badgen.net/badge/DefinitelyTyped/.d.ts)](http://definitelytyped.org)\n[![npm](https://badgen.net/npm/dt/camaro)](https://npm.im/camaro)\n## Features\n\n* Transform XML to JSON. Only take properties that you're interested in.\n* Output is a ready to use JS object.\n* Work on all major platforms (OS X, Linux and Windows). See Travis CI and AppVeyor build status for details.\n* SUPER FAST!! We're using [pugixml](http://pugixml.org/) underneath. It's one of the fastest xml parser around.\n\nHere are the benchmarks:\n\n```\ncamaro x 809 ops/sec ±1.51% (86 runs sampled)\nrapidx2j x 204 ops/sec ±1.22% (81 runs sampled)\nxml2json x 53.73 ops/sec ±0.58% (68 runs sampled)\nxml2js x 40.57 ops/sec ±7.59% (56 runs sampled)\nfast-xml-parser x 148 ops/sec ±3.43% (74 runs sampled)\nxml-js x 33.38 ops/sec ±6.69% (60 runs sampled)\nlibxmljs x 127 ops/sec ±15.36% (50 runs sampled)\n```\n\n* Please note that **this is an unfair game for camaro** because it only transform those fields specified in template.\nThe whole reason of me creating this is because most of the time, I'm just interested in some of the data in the whole XML mess.\n\n* Benchmark run on MacBookPro14,1 - Intel Core i5 CPU @ 2.30GHz using Node v8.10.0.\n\n* I may expose another method to transform the whole XML tree so that the benchmark will better reflect the real performance.\n\n* Performance on small XML strings is not very good due to crossing between JS and C++ is expensive.\n\n![intro](intro.png)\n\n## Installation\n\n```sh\nyarn add camaro\n# npm install camaro\n```\n\n## Usage\n\nYou can use our custom template format powered by [XPath](https://developer.mozilla.org/en-US/docs/Web/XPath).\n\nWe also introduce some custom syntax such as:\n\n* if a path start with `#`, that means it's a constant. E.g: `#1234` will return `1234`\n* if a path is empty, return blank\n* Some string manipulation functions which are not availble in XPath 1.0 such as `lower-case`, `upper-case`, `title-case`, `camel-case`, `snake-case` and `string-join`. Eventually, I'm hoping to add all XPath 2.0 functions but these are all that I need for now. PRs welcome.\n\nThe rest are pretty much vanilla XPath 1.0.\n\n\n```js\nconst transform = require('camaro')\nconst fs = require('fs')\n\nconst xml = fs.readFileSync('examples/ean.xml', 'utf-8')\nconst template = {\n    cache_key: '/HotelListResponse/cacheKey',\n    hotels: ['//HotelSummary', {\n        hotel_id: 'hotelId',\n        name: 'name',\n        rooms: ['RoomRateDetailsList/RoomRateDetails', {\n            rates: ['RateInfos/RateInfo', {\n                currency: 'ChargeableRateInfo/@currencyCode',\n                non_refundable: 'boolean(nonRefundable = \"true\")',\n                price: 'number(ChargeableRateInfo/@total)'\n            }],\n            room_name: 'roomDescription',\n            room_type_id: 'roomTypeCode'\n        }]\n    }],\n    session_id: '/HotelListResponse/customerSessionId'\n}\n\nconst result = transform(xml, template)\n```\n\n### Namespaces\n\nBy default, a path `'//HotelSummary'` will transform all `HotelSummary` elements regardless of their namespaces. To only transform elements under a specific namespace, say `http://v3.hotel.wsapi.ean.com`, you can append the path with a filter:\n\n    '//HotelSummary[namespace-uri() = \"http://v3.hotel.wsapi.ean.com\"]'\n\n## Using camaro on AWS Lambda\n\nIn order to use `camaro` on AWS Lambda, you should download a copy of prebuilt camaro from [Releases](https://github.com/tuananh/camaro/releases) and put to this folder path `node_modules/camaro/lib/binding/camaro.node`.\n\nAs of currently, AWS Lambda only supports node 6 on Linux so you're looking for `camaro-v2.1.0-node-v48-linux-x64.tar.gz`.\n\n## Licence\n\n[The MIT License](LICENSE)","readmeFilename":"README.md","gitHead":"561cddee32dbd4274bc6d1dc321c10773c911fe8","_id":"camaro@3.0.19","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-QobHUIfwv84jhB3k9mO5LIJLTANSw5h47Io2HbxdGKFPVYZO3a78pTI0WfBwPrNQPxxYrwA9G1h8fgkfF4oWIQ==","shasum":"08614ebe4f207ec63821db474ed4b1687a82f5a8","tarball":"http://registry-npm.ywwl.com/camaro/download/camaro-3.0.19.tgz","fileCount":580,"unpackedSize":3145658,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeAZUICRA9TVsSAnZWagAA7sEP/iCOLtSYOGKIkPqsTP7V\nJghxM/pIduj9BFEcnDsU9U/qsMYuPlwCw5sVGUQEq7xgB8AFTKU0CnqDBWBc\nIun4b2RVM/YVPImDJD9zE/WtJURFP0Stv7DLQNtkH4Ojfn12afsNuADrOULU\nif0aeFcUa4Juh9vJBGyqjvOFO/QKV9hRsRnIvmpV6omwKhdPSCTG8az8MMye\nnS1r76Rf/7Dvtu0U8AxYNpLewKZ6yO5Azk3pDQqxwY2S13NePOuCKfoKMnye\nMrccjQLHNFbUxzbkjtyA8t3rr+VbV/4ZhbITXS/bFwgjyxjYxjYpBp71hTjy\nB1VFP7u/b/MuktbQpzV/A1HU5HojQo/TE6+qaLlke5Vimc8Tq11DE47ca5+d\nL1RxLApqNtEErJ417uDzmcBid/Vl8fbQ4L0oMtHbU/eyPnMYvQUdQsWoKzcY\nXMoOmOeHn9GNwaWnPwE49GmX9K8ziGmeK1JV9TiqQPgsvZMZq1j9n/7Ebrom\nmJ7Wdhw3cV6aXvi/lp9VYPefaJJ6K4Fqt4qP7uRsRC9zQGeHw7jj57Qas5Hz\n42BXfn9w0E+ycM5Nzo1Ii78GFZcHW5WnBR6r5mVX0xfZYOVPkV758ilJW4Bs\nvvUYhtbxNTH8vnXxLQXxD2R6w3LzIqdxa0Qq80jaSCKno0Pz4lcUutlxA/n/\nPLaV\r\n=smLk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/FnVxSF0X8xU60/N7zJDV0V5PGRo7xw0V0Q59S2SZ0gIhAIuKHnCSyl/wKrxekCEWK6oFRRJ88YofMFtjEd3tHIyP"}],"size":826244,"noattachment":false,"key":"/camaro/-/camaro-3.0.19.tgz"},"maintainers":[{"name":"tuananh","email":"me@tuananh.org"}],"_npmUser":{"name":"tuananh","email":"me@tuananh.org"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/camaro_3.0.19_1577161992366_0.7080789523742703"},"_hasShrinkwrap":false,"publish_time":1577161992562,"_cnpm_publish_time":1577161992562,"dist-tags":{"latest":"6.7.3","legacy-v3":"3.0.20","next":"6.5.0-rc4","oldv3":"3.0.19"}}