Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
Modifying json file via Javascript

I am new to Javascript and have already programmed a system where I can search up and filter the users in my data.json file. But how can I build an application that can add users to the data.json file. Thank you for your help, Benjamin

HTML:

<html lang="en">
    <head>
        <link rel="Stylesheet" href="style.css">
        <script src="main.js"></script>
    </head>
    <body>
        <input class="name" placeholder="name">
        <input class="email" placeholder="email">
        <button class="submit">Add User</button>
    </body>
</html>

JSON:

[
  {
      "id": 1,
      "name": "Leanne Gr",
      "email": "Sincere@april.biz"
  }
]
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use the npm package

browserify-fs

to do that. When you installed the package you can use the fileSystem.writeFile() function:

const fileSystem = require("browserify-fs")

const client = {
 "Name": "John Doe",
 "Mail": "mail@gmail.com"
}
const data = JSON.stringify(client)

fileSystem.writeFile("./data.json", data, err=>{
 if(err){
   console.log("Error writing file" ,err)
 } else {
   console.log('JSON data is written to the file successfully')
 }
})

about 4 years ago · Juan Pablo Isaza Report

0

You Can do this with XMLHttpRequest requests. But you need a server to host your json.

You can host a local server using json-server npm package to host your own JSON server

In conclusion you need a server and XMLHttpRequest to edit using Javascript

Other wise you need a Server Side program language like PHP

Note that Javascript Client Side programming Language

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!