Registry / storage / athena-struct-parser

athena-struct-parser

JSON →
library1.1.0jsnpmunverified

A lightweight parser for converting AWS Athena struct and array strings into native JavaScript objects. Current version 1.1.0 is stable with a simple API and no external dependencies. Unlike naive regex or manual parsing, it handles nested structs, arrays, and unescaped characters correctly. This is the only dedicated npm package for this specific Athena output format, filling a gap left by query wrappers like athena-express.

npm install athena-struct-parser
INSTALL
IMPORT
SIG · ATHENA-STRUCT-PARS
A
athena-struct-parser
storagejavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parseStruct
import parseStruct from 'athena-struct-parser'
const parseStruct = require('athena-struct-parser')
Package is ESM-only; no default CommonJS support.
parseStruct
import parseStruct from 'athena-struct-parser'
import { parseStruct } from 'athena-struct-parser'
The module exports a single function as default, not a named export. Named imports will fail.
parseStruct
const parseStruct = (await import('athena-struct-parser')).default
For dynamic imports in CommonJS or Node <16, use dynamic import with .default access.

Parses an Athena struct string into a JavaScript object, demonstrating usage with athena-express results.

import parseStruct from 'athena-struct-parser'; const athenaResult = { Items: [ { struct: '{foo=bar, baz=[{foe=moe}]}', foo: 'baz', bar: 'zab' } ] }; const parsed = athenaResult.Items.map(item => ({ ...item, struct: parseStruct(item.struct) })); console.log(parsed[0].struct); // { foo: 'bar', baz: [{ foe: 'moe' }] }
Debug
Known issues
gotchaInput must be a string in Athena struct format, e.g., {key=value}. Passing arbitrary JSON or other formats will produce incorrect results or throw an error.
fix
Ensure input string matches Athena's struct representation exactly, including braces and equals signs.
affects: <1.1.0
gotchaThe function does not validate that the input is a well-formed struct. Malformed strings may return unexpected objects or throw.
fix
Wrap calls in try-catch or pre-validate input if data quality is uncertain.
affects: >=1.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token '='
Passing a JSON string (e.g., '{"foo":"bar"}') instead of an Athena struct string.
fix
Use the Athena struct format: '{foo=bar}' not '{"foo":"bar"}'.
TypeError: parseStruct is not a function
Named import instead of default import (e.g., import { parseStruct } from 'athena-struct-parser').
fix
Use default import: import parseStruct from 'athena-struct-parser'.
RangeError: Maximum call stack size exceeded
Parsing an extremely deeply nested struct (practical limit not documented).
fix
Limit nesting depth or use iterative parsing (not available in this library); consider sampling or truncation.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
46 hits · last 30 days
node
40
OpenAI (training)
1
Resources
athena-struct-parser — npm install athena-struct-parser · libregistry