// json.Marshal outputs any empty object or array as {} & [] -- this routine will
// convert those to the multi-line versions the rex functions need; which will later
// convert them back...
json.Marshal outputs any empty object or array as {} & [] -- this routine will
convert those to the multi-line versions the rex functions need; which will later
convert them back
// json . Marshal outputs any empty object or array as {} & [] -- this routine will // convert those to the multi - line versions the rex functions need ; which will later // convert them back ...
func fixEmptyObjectsAndArrays(src string) string {
	namedObjectRex := regexp.MustCompile(`((?sm).*?^)( *)("\w+?": {)((?s)}.*)`)
	src = RexReplace(src, namedObjectRex, func(x []string, rx *regexp.Regexp, rf RexFunc) string {
		return x[1] + x[2] + x[3] + "\n" + x[2] + RexReplace(x[4], rx, rf)
	})
	return src
}
func fixEmptyObjectsAndArrays ( src string ) string { namedObjectRex := regexp . MustCompile ( `((?sm).*?^)( *)("\w+?": {)((?s)}.*)` ) src = RexReplace ( src , namedObjectRex , func ( x [ ] string , rx * regexp . Regexp , rf RexFunc ) string { return x [ 1 ] + x [ 2 ] + x [ 3 ] + " \n " + x [ 2 ] + RexReplace ( x [ 4 ] , rx , rf ) } ) return src }
json.Marshal outputs any empty object or array as {} & [] -- this routine will
convert those to the multi-line versions the rex functions need; which will later
convert them back
json . Marshal outputs any empty object or array as {} & [] -- this routine will convert those to the multi - line versions the rex functions need ; which will later convert them back
// test only uses empty named objects (for now) //	namedArrayRex := regexp.MustCompile(`((?sm).*?^)( *)("\w+?": \[)((?s)\].*)`) //	unnamedObjectRex := regexp.MustCompile(`((?sm).*?^)( *)({)((?s)}.*)`) //	unnamedArrayRex := regexp.MustCompile(`((?sm).*?^)( *)(\[)((?s)\].*)`)