Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda