Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jsonArray = JSON.parse(File.open(JSON_filePath).read)
- jsonArray << node_to_insert
- File.open(JSON_FilePath,"w") do |f|
- f.write(JSON.pretty_generate(jsonArray))
- end
- jsonArray = [node_to_insert] # initialize to array with your first row
- jsonArray.push( *JSON.parse(File.open(JSON_filePath).read) ) # push results,
- # use the splat operator (*) to avoid array nesting
- jsonArray = JSON.parse(File.open(JSON_filePath).read)
- jsonArray.prepend(node_to_insert)
Add Comment
Please, Sign In to add comment