XML / JSON 转换器,支持普通 XML 和 <plist>。属性写成 @name,文本节点写成 #。
XML / JSON converter with plist support. Attributes are stored under @name, and text nodes under #.
发布源:
- npm: https://www.npmjs.com/package/@nsnanocat/xml
- GitHub Packages: https://github.com/NSNanoCat/XML/pkgs/npm/xml
npm install @nsnanocat/xmlnpm config set @nsnanocat:registry https://npm.pkg.github.com
# GitHub Packages requires a token with package read access.
# echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT" >> ~/.npmrc
npm install @nsnanocat/xmlimport XML from "@nsnanocat/xml";
const xml = '<root foo="bar"><child>text</child></root>';
const json = XML.parse(xml);
const output = XML.stringify(json);
console.log(json);
console.log(output);import XML from "@nsnanocat/xml";
const plist = XML.parse("<plist><dict><key>n</key><integer>1</integer></dict></plist>");
// { plist: { n: 1n } }Parse XML into a JSON-like object. <plist> is handled specially and plist integers are returned as BigInt.
Serialize a JSON-like object back to XML. Pass "" for compact output or a tab string to replace indentation.
Print the package name and version.
Published package entry point: XML.mjs. XML.beta.mjs stays in the repo as the verbose beta build.
npm run format
npm run lint
npm test
npm run typecheck
npm run check
npm pack --dry-run