Question: I am getting response from server where the key is not with quotes. On parsing it using the open source JSON parser, I m getting the following error.

> 
> -JSONValue failed. Error is: Unrecognised leading character
> 
> 
> 

& if I add double quotes (") to the key manually, I get what I want.
What do I do?

Thanx a lot in advance.

**EDIT:**
please see the following, if its correct

```
{

    status: 200,
    statusMsg: "Success",
    statusInfo: {
        custType: "Active",
        custCount: 600,
        custAccount: "Premium" 
    },
    custInfo: {
        custName: "ABC",
        custCode: "CU102",
        custNumber: 9281 
    },
    errors: [

    ]

}

```

Answer: 
> 
> Update for Swift 4
> 
> 
> 

I was looking for a way to parse JSON that has keys without quotes, and I finally found a simple way to do it by using regex. This is the regex needed to match the keys without quotes:

```
(\\\"(.*?)\\\"|(\\w+))(\\s*:\\s*(\\\".*?\\\"|.))

```

To add the quotes, replace with `\"$2$3\"$4`.

Example:

```
let string = "{ custType: \"Active\", custAccount: \"Premium\" }"
let regex = string.replacingOccurrences(of: "(\\\"(.*?)\\\"|(\\w+))(\\s*:\\s*(\\\".*?\\\"|.))", with: "\"$2$3\"$4", options: .regularExpression)
print(regex)

```

Output:

```
{ "custType": "Active", "custAccount": "Premium" }

```
Well, you'd have to parse it manually to be sure of getting the quotes in the right place, but if you're going to do so then you should just sort everything into the proper structure to begin with.

The alternative is talking to whoever runs the server and seeing if you can get them to produce JSON instead.