I have a SNS JSON message here: https://s.natalian.org/2016-12-15/sns-event.json
However I need to use the Message field as a payload for a JSON data structure. How do I quickly get a piece of JSON inserted so the final JSON looks like: https://s.natalian.org/2016-12-15/sns-event-stringified-message.json
"Message": "[{\"From\": \"foo\",\"To\": \"bar\"}]",
For the sake of this example, file.json to be inserted has the contents:
[
{
"From": "foo",
"To": "bar"
}
]
I'm doing it by hand currently with JSON.stringify
which error prone with a large structure.
Read the other file in as an argument file, then assign the new message value from the file. You can obtain a stringified version of the current object using
tojson
(or@json
).