I have a large json file like this:
{
"height": 2.5,
"status": "open",
"date": 1662645600000,
"batch": {
"food": {
"-NBml_1X3O1H6Yrkr3LN0": {
"qty": 5.35,
"date": 1663004201119
},
"-NBmlcwczvQSgQauMBky0": {
"qty": 5.65,
"date": 1663197837636
}
},
"growth": {
"-NBml_1X3O1H6Yrr3LN0": {
"rate": 7.35,
"date": 1663004201219
},
"-NBmlcwczvQSQauMBky2": {
"rate": 5.4,
"date": 1663197837936
}
},
"date": 1663197837037
}
}
I would like to add 864000000 (10 days) to each date
field
How can I do that using vscode, jsoneditor or a simple dart code?
4
Answers
You can use the "Transform" Feature of JsonEditorOnline.org. On the Lodash Query box, you can use the following function:
It will sum 10 days to each unix timestamp
date
fieldWith the extension Regex Text Generator
"data":
text that needs updating. You can do that globally with Find andAlt+Enter
or any other method you likeArrowRight
ArrowRight
Shift+End
(.*)
{{=N[1]+864000000}}
Enter
in input box of generator regexEsc
in input box of generator regexEsc
to leave Multi Cursor ModeYou can do that with a very simple dart program. It would read the file, jsonDecode it, recursively find the correct key, and add the desired amount to each date value. OR you could solve it in dart using a regex, which is even simpler:
You could do the same with a simple
sed
command. This should work (but not verified):You can do that in vscode with an extension that can do math easily, Find and Transform (which I wrote). With a keybinding like this: