“NodeJs Añadir a JSON” Código de respuesta

NodeJs Añadir a JSON

//Because we want JSON format to the file, we first need to read the file
//parse the data to JS object
//push the new items
//and then overwrite the file
var fs = require('fs')

var currentSearchResult = 'example'

fs.readFile('results.json', function (err, data) {
    var json = JSON.parse(data)
    json.push('search result: ' + currentSearchResult)

    fs.writeFile("results.json", JSON.stringify(json))
})
Sugared Bun

NodeJs Añadir a JSON

var fs
json.push
Dead Dragonfly

Respuestas similares a “NodeJs Añadir a JSON”

Preguntas similares a “NodeJs Añadir a JSON”

Más respuestas relacionadas con “NodeJs Añadir a JSON” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código