Gathering detailed insights and metrics for camaro
Gathering detailed insights and metrics for camaro
Gathering detailed insights and metrics for camaro
Gathering detailed insights and metrics for camaro
npm install camaro
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
556 Stars
697 Commits
29 Forks
8 Watching
4 Branches
9 Contributors
Updated on 15 Nov 2024
JavaScript (59.27%)
C++ (31.22%)
HTML (6.9%)
Shell (2.61%)
Cumulative downloads
Total Downloads
Last day
-15.3%
2,022
Compared to previous day
Last week
-13.7%
10,973
Compared to previous week
Last month
-2.5%
52,960
Compared to previous month
Last year
-17.4%
683,110
Compared to previous year
1
7
camaro is a utility to transform XML to JSON, using Node.js bindings to a native XML parser pugixml - one of the fastest XML parsers around.
Transform XML to JSON.
Written in C++ and compiled down to WebAssembly, so no re-compilation needed.
It's pretty fast on large XML strings.
worker_threads
pool (Node >= 12).Pretty print XML.
300 KB XML file | 100 KB XML file |
---|---|
60 KB XML file | 7 KB XML file |
---|---|
The XML file is an actual XML response from the Expedia API. I just deleted some nodes to change its size for benchmarking.
For complete benchmark, see benchmark/README.md.
rapidx2j
and xml2json
, no longer work on Node 14, so I removed them from the benchmark.1yarn add camaro 2# npm install camaro
You can use our custom template format powered by XPath.
We also introduce some custom syntax such as:
#
, that means it's a constant. E.g, #1234
will return 1234
lower-case
, upper-case
, title-case
, camel-case
, snake-case
, string-join
or raw
. Eventually, I'm hoping to add all XPath 2.0 functions but these are all that I need for now. PRs are welcome.The rest are pretty much vanilla XPath 1.0.
For complete API documentation, please see API.md
Additional examples can be found in the examples folder at https://github.com/tuananh/camaro/tree/develop/examples or this comprehensive blog post by Ming Di Leom.
1const { transform, prettyPrint } = require('camaro') 2 3const xml = ` 4 <players> 5 <player jerseyNumber="10"> 6 <name>wayne rooney</name> 7 <isRetired>false</isRetired> 8 <yearOfBirth>1985</yearOfBirth> 9 </player> 10 <player jerseyNumber="7"> 11 <name>cristiano ronaldo</name> 12 <isRetired>false</isRetired> 13 <yearOfBirth>1985</yearOfBirth> 14 </player> 15 <player jerseyNumber="7"> 16 <name>eric cantona</name> 17 <isRetired>true</isRetired> 18 <yearOfBirth>1966</yearOfBirth> 19 </player> 20 </players> 21` 22 23/** 24 * the template can be an object or an array depends on what output you want the XML to be transformed to. 25 * 26 * ['players/player', {name, ...}] means that: Get all the nodes with this XPath expression `players/player`. 27 * - the first param is the XPath path to get all the XML nodes. 28 * - the second param is a string or an object that describe the shape of the array element and how to get it. 29 * 30 * For each of those XML node 31 * - call the XPath function `title-case` on field `name` and assign it to `name` field of the output. 32 * - get the attribute `jerseyNumber` from XML node player 33 * - get the `yearOfBirth` attribute from `yearOfBirth` and cast it to number. 34 * - cast `isRetired` to true if its string value equals to "true", and false otherwise. 35 */ 36 37const template = ['players/player', { 38 name: 'title-case(name)', 39 jerseyNumber: '@jerseyNumber', 40 yearOfBirth: 'number(yearOfBirth)', 41 isRetired: 'boolean(isRetired = "true")' 42}] 43 44;(async function () { 45 const result = await transform(xml, template) 46 console.log(result) 47 48 const prettyStr = await prettyPrint(xml, { indentSize: 4}) 49 console.log(prettyStr) 50})()
Output of transform()
[
{
name: 'Wayne Rooney',
jerseyNumber: 10,
yearOfBirth: 1985,
isRetired: false,
},
{
name: 'Cristiano Ronaldo',
jerseyNumber: 7,
yearOfBirth: 1985,
isRetired: false,
},
{
name: 'Eric Cantona',
jerseyNumber: 7,
yearOfBirth: 1966,
isRetired: true,
}
]
And output of prettyPrint()
<players>
<player jerseyNumber="10">
<name>Wayne Rooney</name>
<isRetired>false</isRetired>
<yearOfBirth>1985</yearOfBirth>
</player>
<player jerseyNumber="7">
<name>Cristiano Ronaldo</name>
<isRetired>false</isRetired>
<yearOfBirth>1985</yearOfBirth>
</player>
<player jerseyNumber="7">
<name>Eric Cantona</name>
<isRetired>true</isRetired>
<yearOfBirth>1966</yearOfBirth>
</player>
</players>
...
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
binaries present in source code
Details
Reason
badge detected: InProgress
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/24 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More