Using Regex:
import re
data = """{ Name: "test", Address: "xyz"}"""
print( re.sub("(\w+):", r'"\1":', data) )
Output:
{ "Name": "test", "Address": "xyz"}
More Related Contents:
- How do I write JSON data to a file?
- How to use a variable inside a regular expression?
- Single vs double quotes in JSON
- Reading rather large JSON files [duplicate]
- Split a string at uppercase letters
- How to split but ignore separators in quoted strings, in python?
- Python regex match OR operator
- Python Regex escape operator \ in substitutions & raw strings
- How to extract an IP address from an HTML string?
- Regex for existence of some words whose order doesn’t matter
- Split string on commas but ignore commas within double-quotes?
- Python/Regex – How to extract date from filename using regular expression?
- How would I get everything before a : in a string Python
- Python regex: splitting on pattern match that is an empty string
- flattening nested Json in pandas data frame
- Python: Trying to Deserialize Multiple JSON objects in a file with each object spanning multiple but consistently spaced number of lines
- How to convert to a Python datetime object with JSON.loads?
- Cast Flask form value to int
- Serialising an Enum member to JSON
- How to remove symbols from a string with Python? [duplicate]
- How to find and replace nth occurrence of word in a sentence using python regular expression?
- Regex to match digits of specific length
- Python JSON encoder to support datetime?
- json reading error json.decoder.JSONDecodeError: Invalid \escape
- Regular expression that finds and replaces non-ascii characters with Python
- How to validate an Email address in Django? [duplicate]
- Reading an JSON file from S3 using Python boto3
- Using ^ to match beginning of line in Python regex
- How to split long regular expression rules to multiple lines in Python
- Python regular expression not matching