I'm trying to prettify a JSON object in Notepad++. The first solution that comes to mind is using a dedicated plugin. The thing is that the computer I'm working on is not connected to the Internet and all I can use is Notepad++ and all the functionalities Windows 10 offers.
Let's say this is the JSON object
'ugly' version:
{"_class":"value_to_be_ignored","first_key":{"second_key":{"user_id":"123456","company_id":"9876","question":{"subject":"some_subject","case_type":"urgent","from_date":{"year":2011,"month":11,"day":11},"to_date":{"year":2012,"month":12,"day":12}},"third_key":[{"role":"driver","weather":"great"},{"role":"father","weather":"rainy"}]}}}
and 'pretty' version I would like to get as the result:
{
"_class": "value_to_be_ignored",
"first_key": {
"second_key": {
"user_id": "123456",
"company_id": "9876",
"question": {
"subject": "some_subject",
"case_type": "urgent",
"from_date": {
"year": 2011,
"month": 11,
"day": 11
},
"to_date": {
"year": 2012,
"month": 12,
"day": 12
}
},
"third_key": [
{
"role": "driver",
"weather": "great"
},
{
"role": "father",
"weather": "rainy"
}
]
}
}
}
I know that it is feasible to enter Enter + Tab combination while going through the file manually. The target file is quite large so I want to automate the process.
I know that I can use regex. The following example creates new line - it's helpful but doesn't solve my problem fully. The problem is that I don't know to handle tabulation and closing parentheses:
I wonder whether it's possible to come up with a pair of RegExes for Find what:
and Replace with:
that gets us from the ugly version to the pretty version.