How do I replace a double quote in json string and regular expressions?
Input Json is:
"RegDateTime" : 1481641851263, "Code":"123213",....
and Output should be:
"RegDateTime" : "1481641851263", "Code":"123213",....
I want to fix only json key value that is RegDateTime.
Please suggest any regular expression and replace with double quote in go language.
func ReplaceAllNumber(json string)(string) {
re := regexp.MustCompile("(:\\s*)(\\d+)(\\s*[,}\\]])")
return re.ReplaceAllString(json, "$1\"$2\"$3")
}
func ReplaceNumberWithField(json string, fieldName string)(string) {
regString := fmt.Sprintf("(\"%s\"\\s*:\\s*)(\\d+)(\\s*[,}\\]])", fieldName)
re := regexp.MustCompile(regString)
return re.ReplaceAllString(json, "$1\"$2\"$3")
}