I have several JSON files, and I am writing a mode that allows you to edit one property of a JSON object independently of the rest. For instance:
foo.json:
{
"creation_timestamp": "1411210038.000000",
"description": "lorem ipsum.\ndolor sit amet.",
"version": 4
}
Opening foo.json results in this buffer:
lorem ipsum.
dolor sit amet.
Changing the first line to "foo bar" and saving the file results in foo.jsononly with the updated field description:
{
"creation_timestamp": "1411210038.000000",
"description": "foo bar.\ndolor sit amet.",
"version": 4
}
What is the best strategy for this? My current attempt is this:
- open the json file with find file
- create an invisible overlay from min-point to max-point
- parse json
- insert the value of the property
descriptionin point-min, creating a "view" - add the hook of the local write file and the hook after saving
local-write-file "" , json . after-save "" , .
. , ?