rdotjson is a Node.js library dedicated to parsing Android String Resource XML files (e.g., `strings.xml`) into a structured JavaScript object. It mirrors Android's `R` class access patterns, organizing resources under keys like `R.string`, `R.array`, `R.bool`, `R.color`, `R.dimen`, and `R.integer`. The library supports conversion of these resources into native JavaScript primitives or an object-wrapped format via `objectMode`. The current stable version is 2.0.0, and it maintains an active release cadence, as indicated by ongoing GitHub activity. Its key differentiators include extensive configuration options for handling XML comments, excluding specific keys with wildcards, preserving raw XML, and offering integrated formatters for JSON and CSV output. A robust command-line interface is also provided for direct file processing, making it suitable for build pipelines. It is designed for Node.js environments running version 18.17 or newer.
npm install rdotjsonVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing an Android `strings.xml` file, accessing parsed values, and using the JSON formatter. Includes setup and teardown for a runnable example.
Prefer `import rdotjson from 'rdotjson';` for ESM projects. For CommonJS, `const rdotjson = require('rdotjson');` is still supported, but ensure your Node.js version is compatible.When `objectMode` is enabled, access values via `.value` (e.g., `R.string.app_name.value`). If `objectMode` is not used, access directly (e.g., `R.string.app_name`).
Ensure your Node.js environment is updated to version 18.17 or newer before using `rdotjson`.
Carefully review the documentation for each `comment` option and choose only one that fits your desired output format. Test the output to ensure comments are parsed as expected.
Change the import statement to `import rdotjson from 'rdotjson';` for ESM or `const rdotjson = require('rdotjson');` for CommonJS.Verify the file path is correct and accessible. Ensure the file actually exists on the filesystem where the Node.js process is running.
Inspect the `strings.xml` content for syntax errors, unclosed tags, incorrect encoding, or extraneous characters. Use an XML validator if necessary.
Verify that the resource name matches exactly what is in the XML. If `objectMode: true` is used, access the value via `.value` (e.g., `R.string.app_name.value`). Also, check if the resource type (e.g., `string`) actually contains the key.
No dependency data recorded yet.