Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

forms_to_json

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

forms_to_json

A module for serializing an html form into a JSON object. There is support for file conversion (as base64)

  • 0.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Form to json

A lightweight module (without Jquery) for serializing html forms into a JSON object. In addition, it supports serialization of input fields with files in base64.

npm i forms_to_json -S

Serialize Form

Example serialize HTML form.

import FormToJSON from 'forms_to_json';

const $form = document.querySelector('form');

const json = new FormToJSON($form).parse();
console.log(json);
/*
{
  "author": "12334",
  "year": "1900",
  "isGoldCollection": "yes",
  "type": "v2",
  "hero": [
    "spider-man",
    "batman"
  ]
}
*/

Serialize Form with Files

Files converting to base64.

Example serialize HTML form with files.

import FormToJSON from 'forms_to_json';

const $form = document.querySelector('form');

new FormToJSON($form).parseWithFiles().then((json) => {
  console.log(json);
  /*
  {
    "author": "War and Peace",
    "files": [
      "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABEwAAAJkCAYAAAALLrTbAA...."
      "data:image/png;base64,QLbZMHkY7t0kaPHi3z5s2T0qVLO2wr07p1a8mUKZO21mNf...."
    ]
  }
  */
}).catch(err => {
  console.log(err);
});

Keywords

FAQs

Package last updated on 26 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc