I have a CSON
(Coffeescript JSON) file that looks something like this:
'main key':
subkey:
someKey: 'some value'
someKey: 'some value'
subkey:
someKey: 'some value'
someKey: 'some value'
specialKey: [
'special value X'
'special value Y'
]
subkey:
someKey: 'some value'
someKey: 'some value'
someKey: 'some value'
#And the list goes on and on...
So I want to find and target specialKey
and replace both special value X
and special value Y
to other values, keeping in mind that by the nature of CSON
it is indentation sensitive.
I've thought about getting the line number from specialKey
and replacing the next two line numbers but for the life of me I haven't been able to find a way to edit a specific line by number in Python.
(As a side note, I DO know about the pycson
library but I haven't been able to get it to output anything other than single line JSON
, and I'd rather keep it in CSON as I want to keep readability in a long file and wouldn't want to mess with the user's original file.)