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•1h ago

Comments

chintanshah35•1h 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

Show HN: BlinkFund – Crowdfunding w Solana Blinks (donate directly from Twitter)

https://blinkfund.vercel.app/
1•aayushcb•2m ago•0 comments

I Test Drove a Chinese EV. Now I Don't Want to Buy American Cars Anymore

https://www.wsj.com/tech/personal-tech/chinese-ev-test-drive-xiaomi-su7-c3e59282
1•bookofjoe•2m ago•1 comments

Wyoming Introduces First-Ever Foreign Censorship Shield Bill

https://reclaimthenet.org/wyoming-introduces-first-ever-foreign-censorship-shield-bill-granite-act
1•mikece•2m ago•0 comments

Deer antler size best predicted by mother's health

https://www.youtube.com/watch?v=BORv-p7npls
1•scottndecker•5m ago•0 comments

I made a website that shows you random cultural moments with zero context

https://infinijest.com
1•hnmouse•5m ago•0 comments

Ask HN: Should a software engineer have research exposure?

2•c_daeda•7m ago•0 comments

Don Lemon interviews Elon Musk (2024) [video]

https://www.youtube.com/watch?v=hhsfjBpKiTw
3•irthomasthomas•9m ago•0 comments

AI Doubling Time Horizon v1.1

https://metr.org/blog/2026-1-29-time-horizon-1-1/
1•chriskanan•10m ago•0 comments

Major Epstein files are now publicly viewable across multiple official archives

https://twitter.com/polydao/status/2002143534800044520
2•websku•10m ago•3 comments

Chat Is Going to Eat the World

https://deadneurons.substack.com/p/chat-is-going-to-eat-the-world
1•nr378•14m ago•1 comments

A free MCU watch tracker with achievements for Avengers: Doomsday

https://doomsdayrdy.vercel.app/
1•AlonsoGP•17m ago•1 comments

Ask HN: Blocked by YouTube? (Sign in to confirm you're not a bot)

1•dv35z•17m ago•1 comments

The AI bubble has nothing to do with AI

4•AIFairy•21m ago•0 comments

Dual citizenship could be on the chopping block in America

https://qz.com/dual-citizenship-us-legislation
6•ceejayoz•22m ago•3 comments

Ollama Hosts Form Anonymous AI Network Beyond Platform Guardrails

https://www.sentinelone.com/labs/silent-brothers-ollama-hosts-form-anonymous-ai-network-beyond-pl...
2•toomuchtodo•22m ago•1 comments

Peerweb: Decentralized website hosting via WebTorrent

https://peerweb.lol/
16•dtj1123•22m ago•13 comments

OpenClaw: The Rapid Rise

https://comuniq.xyz/post?t=774
2•01-_-•23m ago•0 comments

Silver plunges 30% in worst day since 1980, gold tumbles

https://www.cnbc.com/2026/01/30/silver-gold-fall-price-usd-dollar-fed-warsh-chair-trump-metals.html
5•pera•24m ago•0 comments

Riding a C90 through India [video]

https://www.youtube.com/watch?v=mPne-q4ynts
1•opengrass•25m ago•0 comments

What GLP-1s Are Accidentally Teaching Us About Our Brains

https://thenextbigthink.substack.com/p/what-happens-when-the-want-gets-quiet
1•krustyburger•26m ago•0 comments

The Hitchhiker's Guide to Measuring Engineering ROI

https://www.ctologic.pro/p/how-to-measure-engineering-roi
1•nadis•30m ago•0 comments

Three thoughts on AI inspired by Clawdbot

https://aistudycamp.com/three-thoughts-on-ai/
5•flreln•31m ago•0 comments

The Cost of AI Art

https://www.brandonsanderson.com/blogs/blog/ai-art-brandon-sanderson-keynote
1•jplusequalt•32m ago•0 comments

Claude planned the latest NASA Mars Rover drive

https://xcancel.com/AnthropicAI/status/2017313346375004487
3•bigwheels•33m ago•0 comments

Show HN: A Postgres-first platform (opening public beta)

1•antoniodipinto•33m ago•0 comments

Job Interview Questions for Embedded Systems Developers

https://www.windriver.com/blog/Internal-Job-Interview-Questions-for-Embedded-Systems-Developers
1•ohjeez•35m ago•0 comments

Show HN: Synatra – OpenClaw for Teams

https://github.com/synatrahq/synatra
1•theaktky•36m ago•0 comments

New coffee chemicals show promise for managing type 2 diabetes

https://medicalxpress.com/news/2026-01-coffee-chemicals-diabetes.html
2•PaulHoule•37m ago•0 comments

Apple tops Q1 earnings estimates on record-breaking iPhone sales

https://finance.yahoo.com/news/apple-tops-q1-earnings-estimates-on-record-breaking-iphone-sales-s...
1•01-_-•38m ago•2 comments

Show HN: HN Comment Thread Analysis

https://github.com/a-Gb/hankerlytics
1•geeunits•39m ago•0 comments