Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
json-form-data
Advanced tools
A library to convert JavasScript objects into FormData.
This library converts a JSON object into FormData, allowing files and primitive data to be sent to a server in a single HTTP request.
Single Page Web Applications (SPA's) primarily use JSON formatted payloads. This causes problems when you need to send a file along with additional data, as files cannot be sent to a server in a JSON formatted payload.
This library addresses the limitations of similar libraries by allowing conversion of deeply nested JSON objects,
better unit test coverage and exclusion of null
and undefined
values from the resulting FormData.
Input as JSON
var testObject = {
prop1: 'test',
prop2: 2,
prop3: null,
prop4: undefined,
prop5: true,
prop6: false,
prop7: new File(['file content'], 'my_file.txt'),
prop8: {
prop1: 'test',
prop2: 2,
prop3: null,
prop4: undefined,
prop5: true,
prop6: false,
prop7: [
'test',
2,
null,
undefined,
true,
false
]
}
};
var formData = window.jsonToFormData(testObject);
Output as multipart/formdata
prop1
test
prop2
2
prop5
1
prop6
0
prop7
Content-Disposition: form-data; name="My File"; filename="my_file.txt"
Content-Type: text/plain
prop8[prop1]
test
prop8[prop2]
2
prop8[prop5]
1
prop8[prop6]
0
prop8[prop7][0]
test
prop8[prop7][1]
2
prop8[prop7][2]
1
prop8[prop7][3]
0
IE / Edge | Firefox | Chrome | Safari |
---|---|---|---|
IE10, IE11, Edge | latest | latest | latest |
We use BrowserStack to automate our regression tests to ensure compatibility with supported browsers.
FAQs
A library to convert javascript objects into form data.
The npm package json-form-data receives a total of 7,766 weekly downloads. As such, json-form-data popularity was classified as popular.
We found that json-form-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.