Situation: You need to cleanly extract just the usernames from a .JSON file, and place each name on a new line. The result should look like…
name1
name2
name3
The value being extracted from the JSON could just as easily be email addresses, or map co-ordinates, or suchlike.
Why you might do this: You can’t just do a simple “.JSON out, .JSON in”. For instance, let’s say you have a Web browser add-on that offers a blocklist function based on usernames. Perhaps it’s the deviantART-Filter. You want to port this 1,600 name blocklist of scum-and-villainy over to a similar browser add-on. Perhaps it’s the dA_ignore UserScript. The old deviantART-Filter usefully exports a .JSON file of your blocked users. But…. the new dA_ignore can only import a pasted-in list of usernames, one per line.
Solution 1:
There is a working Regex for doing this, which only requires a recent copy of Notepad++ and a suitable .JSON file for the process…
It’s been tested and works. The use of the * wildcard will enable the extraction of a list in the form…
path_label”:”any_value_here
After this regex has processed the code you are thus left with a list that looks like…
username”:”name1
username”:”name2
username”:”name3
… and you need only to do a basic search/replace to clear username”:” to obtained your cleaned list of the various unique usernames.
In this use-case you go to your own DeviantArt Settings page, and paste in the new ported-over blocklist.
Solution 2:
1. Open the .JSON with the genuine Windows freeware JSONedit.
2. Filter the JSON on field “username” by typing username into the search box. In ‘List view’ you should now only see a list of the “username” fields and the adjacent data entry.
3. Then go: top menu | ‘Tools’ | ‘Export as .CSV’.
4. Add a file extension .CSV to the saved file if needed, and then open it with Excel. Select and copy out all the “usernames” column to a new Notepad++ file.
5. In Notepad++, a quick search-replace will then remove the “” marks. You now have a clean portable list, with one username per line.
Solution 3:
There are, of course, cloud services in Whereizitagain that may well offer to do this. But the above methods use Windows freeware and are thus more secure.