Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
Add element(Data) to a json file in javascript without node.js

I have done lots of research before I decided to post this question but I still can find a way of adding an element/data to a json file which is stored locally. I have managed to open and read it but not add data. Here is what I would like to happen:

before I run the script.

{"logins" : [

    {        
        "name": "test",
        "usernam": "t",
        "passwor": "ber"
    },

    {
        "name": "test2,
        "usernam": "chi",
        "passwor": "Chik"
    }

]}

and then I really on a button click I would like to add a new element/data so It looks like:

{"logins" : [

    {        
        "name": "test",
        "usernam": "t",
        "passwor": "ber"
    },

    {
        "name": "test2",
        "usernam": "chi",
        "passwor": "Chik"
    },
    {
        "name" : "test3"
        "usernam" : "tester"
        "passwor": "tester2"



]}

and all of this preferably should be done without node.js. I am running this through a script tag in my html

Many thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I assume you have a local .JSON file you are trying to edit with plain JS.

And the answer is no. Without a server, that is practically impossible.

You can however change it client-side, but that'll just be for you, and would never save anywhere else.

This is all for security, because letting a web page change a file... Could also allow it to delete files, including system ones.

Use something simple like Node.js for a backend server that can handle this.

I'd also recommend hashing passwords.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda