Page 1 of 1

Utilities, Tools to use on editing jsons

Posted: Sat Sep 01, 2018 10:56 pm
by Stratego (dev)
i am writing this because idk what untilities are u using currently and i have some nice ones that might help you (for PC)
0. To edit json files or any textfile on PC use TextPad (it is free), it will not ruin any formatting. An phone i used Total commander and its own file editor.
1. If you want to edit multiple jsons at once (eg. adding a category to them) use Notepad ++ you can edit any number of files at once. also mentioned here /viewtopic.php?f=17&t=4422&p=43674&hilit=notepad

also see Edit multiple jsons - regex section below in APPENDIX

2. compare two jsons (to see thechanges) use Total commander it has: Files/Compare By Content option

3. compare many file contents eg. 2 complete asset folders (to see all changes betw. 2 asset folder versions) - use Total commander it has: Commands/Synchronize Dirs option, very good in comparing complete directories and the file contents! (this is the one i use when i receive an asset folder so i quickly see all changes in all files - and i approve them individually - eg. when i have newer version of something )

4. Simply editing jsons: i use TextPad

5. Multi update filenames!: Total Commander there is a multi-file-rename-tool! i was able to rename all _und_ to _undead_ in one click! did u know that?


APPENDIX
Edit multiple jsons - regex
Using notepad ++ you can edit multiple files.
But good news not only by search relpace normal strings but complex expressions.

You can learn and try all your expressions here easily: https://regex101.com/

examples i used:
1. My goal was to replace the trnBestAgainstMeWater strings to something else, and this regex will find all possible formats and i can replace those too (no matter how many spaces, whitespaces, newline characters are in it alsmost anywhere)

Code: Select all

"trnBestAgainstMeWater"\s*:\s*{\s*"categories"\s*:\s*\[\s*"U_SHIPS"\s*\]\s*}
here important regex letters:

Code: Select all

\s*
means any number of whitespace/newline characters

Code: Select all

\[
the [character needs escaping with \

2. use this to find files that has a specific trn bestagainstme category in it

Code: Select all

"trnBestAgainstMe(Water|Ground)":{"categories":\[[\s\w",]*"U_ANTI_MOUNTED"[\s\w",]*\]
3.if you want to find all files with the specific category in it.

Code: Select all

"trnCategories":\[[\s\w",]*"U_ANTI_MOUNTED"[\s\w",]*\]
4. i wanted to remove empty trnCanNotCarryMe TAGs regardless of any spaces or newline characters

Code: Select all

"trnCanNotCarryMe":{\s*},
5. we cleared more unused attributes (handles only one-liners)

Code: Select all

[ \t]+"grantorShopItems"\s*:\s*[^\n]*\n
[ \t]+"trnRequires"\s*:\s*[^\n]*\n
[ \t]+"trnUpgradeAncestor"\s*:\s*[^\n]*\n
[ \t]+"trnRevokerTechs"\s*:\s*[^\n]*\n
[ \t]+"isFactoryThatNotAffectsFactoryLimits"\s*:\s*[^\n]*\n
[ \t]+"isOccupiableBuilding"\s*:\s*[^\n]*\n
[ \t]+"isStealthUnit"\s*:\s*[^\n]*\n

Re: Utilities, Tools to use on editing jsons

Posted: Wed Sep 12, 2018 2:58 am
by Stratego (dev)
5. Multi update filenames!: Total Commander there is a multi-file-rename-tool! i was able to rename all _und_ to _undead_ in one click! did u know that?

Re: Utilities, Tools to use on editing jsons

Posted: Sun Aug 08, 2021 9:16 am
by Stratego (dev)
new example

4. i wanted to remove empty trnCanNotCarryMe TAGs regardless of any spaces or newline characters

Code: Select all

"trnCanNotCarryMe":{\s*},