'Copy and Paste Text into certian spot and lines

so i have this .json file and a lot of text i need to put in there Now i dont want to select everything and paste it one by one to its destination

So for example i have "" and i want paste my text to make it

"paste1"
"paste2"
"paste3"

How would i be able to copy my stuff from the txt, into the .jsons by making every line as seperate line, but keeping it in the same format at the same destination for that line? Like how can i paste stuff between the "" but every paste would end up in a different line?

Hope someone could help me out



Solution 1:[1]

You have to read the txt file into a variable which will store the file data in it. Then you would have to split the data at every new line which will return an array of data that you can manipulate to your liking.

Here's a sample of part of the code you might write using Javascript:

//data is the variable we have stored our txt file info in
let arr = data.split("\n") // <-- splitting the data which returns an array which we store in a variable called "arr"
for(let i=0;i<arr.length;i++){
  arr[i] = "\""+arr[i]+"\"" //arr[i] is the value at every line and we are surrounding it with quotation marks
}

You can of course manipulate the data in whatever way you want and after that you would save the data in any format you'd like.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gNazi