frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: handlejson – Safe JSON parsing without try-catch boilerplate

https://github.com/chintanshah35/handlejson
1•chintanshah35•1w ago

Comments

chintanshah35•1w ago
After years of writing try-catch blocks for every JSON.parse, I built handlejson v1.0.0. It is a zero-dependency, 1.5KB library that eliminates boilerplate while hardening your application against common JSON exploits.

The problem:

  let data
  try {
    data = JSON.parse(str)
  } catch {
    data = null
  }
The solution:

  import { parse } from 'handlejson'
  
  const data = parse(str) // null if invalid, no try-catch needed
  const data = parse(str, { default: {} }) // {} if invalid
Key features:

Hardened Security (Protection against common exploits)

Native JSON.parse is vulnerable to resource exhaustion. handlejson adds:

  maxSize: Blocks memory exhaustion from "JSON bombs."
  maxDepth: Prevents stack overflow from deeply nested objects.
  safeKeys: Automatically blocks prototype pollution (__proto__).

  parse(userInput, {
    maxSize: 10 * 1024 * 1024,
    maxDepth: 100,
    safeKeys: true
  })
High Performance

- Small JSON: 5.2M ops/s - With security checks enabled: 3.4M ops/s - Bundle size: 1.5KB gzipped (Zero dependencies)

Advanced Handling

- Circular References: stringify() handles circular structures automatically.

- Date & BigInt: Automatic serialization and revival without manual revivers.

- Detailed Errors: Precise error position and context instead of "Unexpected token."

- Stream Parsing: Support for parsing large files in chunks.

- Schema Validation: Validate structure without extra dependencies.

- Error Tuples: Get error objects instead of null.

- Validation: Check validity without parsing.

- Format & Minify: Pretty-print or compress JSON.

- Reviver/Replacer: Custom transformation functions (like native JSON).

Reliability:

- 244 tests covering security, streams, and edge cases. - CI/CD tested on Node 18, 20, and 22. - TypeScript-first with full type support.

Blog Post (Deep Dive): https://chintanshah35.hashnode.dev/introducing-handlejson-v1...

GitHub: https://github.com/chintanshah35/handlejson

NPM: https://www.npmjs.com/package/handlejson

More of my work: https://dev.to/chintanshah35

OpenClaw Creator: Why 80% of Apps Will Disappear

https://www.youtube.com/watch?v=4uzGDAoNOZc
1•schwentkerr•45s ago•0 comments

What Happens When Technical Debt Vanishes?

https://ieeexplore.ieee.org/document/11316905
1•blenderob•1m ago•0 comments

AI Is Finally Eating Software's Total Market: Here's What's Next

https://vinvashishta.substack.com/p/ai-is-finally-eating-softwares-total
1•gmays•2m ago•0 comments

Computer Science from the Bottom Up

https://www.bottomupcs.com/
1•gurjeet•2m ago•0 comments

Show HN: I built a toy compiler as a young dev

https://vire-lang.web.app
1•xeouz•4m ago•0 comments

You don't need Mac mini to run OpenClaw

https://runclaw.sh
1•rutagandasalim•5m ago•0 comments

Learning to Reason in 13 Parameters

https://arxiv.org/abs/2602.04118
1•nicholascarolan•7m ago•0 comments

Convergent Discovery of Critical Phenomena Mathematics Across Disciplines

https://arxiv.org/abs/2601.22389
1•energyscholar•7m ago•1 comments

Ask HN: Will GPU and RAM prices ever go down?

1•alentred•7m ago•0 comments

From hunger to luxury: The story behind the most expensive rice (2025)

https://www.cnn.com/travel/japan-expensive-rice-kinmemai-premium-intl-hnk-dst
1•mooreds•8m ago•0 comments

Substack makes money from hosting Nazi newsletters

https://www.theguardian.com/media/2026/feb/07/revealed-how-substack-makes-money-from-hosting-nazi...
5•mindracer•9m ago•1 comments

A New Crypto Winter Is Here and Even the Biggest Bulls Aren't Certain Why

https://www.wsj.com/finance/currencies/a-new-crypto-winter-is-here-and-even-the-biggest-bulls-are...
1•thm•9m ago•0 comments

Moltbook was peak AI theater

https://www.technologyreview.com/2026/02/06/1132448/moltbook-was-peak-ai-theater/
1•Brajeshwar•10m ago•0 comments

Why Claude Cowork is a math problem Indian IT can't solve

https://restofworld.org/2026/indian-it-ai-stock-crash-claude-cowork/
1•Brajeshwar•10m ago•0 comments

Show HN: Built an space travel calculator with vanilla JavaScript v2

https://www.cosmicodometer.space/
2•captainnemo729•10m ago•0 comments

Why a 175-Year-Old Glassmaker Is Suddenly an AI Superstar

https://www.wsj.com/tech/corning-fiber-optics-ai-e045ba3b
1•Brajeshwar•10m ago•0 comments

Micro-Front Ends in 2026: Architecture Win or Enterprise Tax?

https://iocombats.com/blogs/micro-frontends-in-2026
1•ghazikhan205•13m ago•0 comments

These White-Collar Workers Actually Made the Switch to a Trade

https://www.wsj.com/lifestyle/careers/white-collar-mid-career-trades-caca4b5f
1•impish9208•13m ago•1 comments

The Wonder Drug That's Plaguing Sports

https://www.nytimes.com/2026/02/02/us/ostarine-olympics-doping.html
1•mooreds•14m ago•0 comments

Show HN: Which chef knife steels are good? Data from 540 Reddit tread

https://new.knife.day/blog/reddit-steel-sentiment-analysis
1•p-s-v•14m ago•0 comments

Federated Credential Management (FedCM)

https://ciamweekly.substack.com/p/federated-credential-management-fedcm
1•mooreds•14m ago•0 comments

Token-to-Credit Conversion: Avoiding Floating-Point Errors in AI Billing Systems

https://app.writtte.com/read/kZ8Kj6R
1•lasgawe•14m ago•1 comments

The Story of Heroku (2022)

https://leerob.com/heroku
1•tosh•15m ago•0 comments

Obey the Testing Goat

https://www.obeythetestinggoat.com/
1•mkl95•15m ago•0 comments

Claude Opus 4.6 extends LLM pareto frontier

https://michaelshi.me/pareto/
1•mikeshi42•16m ago•0 comments

Brute Force Colors (2022)

https://arnaud-carre.github.io/2022-12-30-amiga-ham/
1•erickhill•19m ago•0 comments

Google Translate apparently vulnerable to prompt injection

https://www.lesswrong.com/posts/tAh2keDNEEHMXvLvz/prompt-injection-in-google-translate-reveals-ba...
1•julkali•19m ago•0 comments

(Bsky thread) "This turns the maintainer into an unwitting vibe coder"

https://bsky.app/profile/fullmoon.id/post/3meadfaulhk2s
1•todsacerdoti•20m ago•0 comments

Software development is undergoing a Renaissance in front of our eyes

https://twitter.com/gdb/status/2019566641491963946
1•tosh•20m ago•0 comments

Can you beat ensloppification? I made a quiz for Wikipedia's Signs of AI Writing

https://tryward.app/aiquiz
1•bennydog224•21m ago•1 comments