JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q37066F
  • License MIT

Parse any kind of broken json for scrapping easily

Package Exports

  • @yoannchb/wtf-json
  • @yoannchb/wtf-json/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@yoannchb/wtf-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

wtf-json

Parse any kind of broken json for scrapping easily.

Goal

The primary objective is to ensure error-free parsing of JSON data. This tool enables you to parse any JSON or JavaScript object, regardless of its validity. Whether the input is a valid JSON or not, you can rely on this tool to handle it seamlessly without encountering any errors.

Install

$ npm i @yoannchb/wtf-json

Or with the CDN

<script src="https://unpkg.com/@yoannchb/wtf-json@1.0.0/dist/index.js"></script>

Import

Only for nodejs and module script

import wtfJson from "wtf-json";
//or
const wtfJson = require("wtf-json");

Example of brokens JSON with output

wtfJson(
  '{ name Yoann, :"isAdmin":: true,, address: { country: `CA` }, null, {}, "roles": [::,,\'admin\' client, :user], emoji: ":happy:" }'
);
/*
 * Will be parse as follow:
 * {
 *  name: "Yoann",
 *  isAdmin: true,
 *  address: {
 *   country: "CA"
 *  },
 *  roles: ["admin", "client", "user"],
 *  emoji: ":happy:"
 * }
 */

wtfJson(`null,null
,null,\\n 
{ data: [{ "id": 6 }] }`);
/*
 * Will be parse as follow:
 * [
 *  null,
 *  null,
 *  null,
 *  "\n",
 *  {
 *   data: { id: 6 },s
 *  }
 * ]
 */