google / google/json5format

Support option to normalize string quotes

Open
#3 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
118
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Simple quoted strings with inconsistent quotes might look like:

```json5
[
'string1',
"string2",
]
```

The current version (0.1.0) does not change the quote style from the original input, in case the selected quote style was intentional. For example:

```json5
{
nickname: 'Tracy "The OG" Morgan',
agent: "Doug O'Dell",
personal_trainer: "Stupid Judy of EPCOT",
}
```

A possible setting would specify the desired quote style. If, for the first example, double-quote is preferred, the result would be:

```json5
[
"string1",
"string2",
]
```

Perhaps the desired quote should only apply if the string has no embedded quotes of the same style as the selected quote style. Otherwise, just use the original quote style for that given value. For the second example, preferring double-quotes would result in the same mixed quote style as the original input, but preferring single-quotes would change only the last property:

```json5
{
nickname: 'Tracy "The OG" Morgan',
agent: "Doug O'Dell",
personal_trainer: 'Stupid Judy of EPCOT',
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.