Crate status
Pipeline status
Installation
cargo add json_keyquotes_convert
Example usage
- For more information, look at the docs.
Using the builder pattern (recommended):
use ;
let json = new
.add_key_quotes.json_escape_ctrlchars.json;
// JSON string will now be: {\"key\": \"va\\nl\"}
// Raw JSON will now be: {"key": "va\nl"}
Using functions:
use ;
let json_added = json_add_key_quotes;
let json_escaped = json_escape_ctrlchars;
// JSON string will now be: {\"key\": \"va\\nl\"}
// Raw JSON will now be: {"key": "va\nl"}
Important information
Crate support legend
| Great | Good | Unsupported |
|---|---|---|
| :heavy_check_mark: | :white_check_mark: | :x: |
| Automatically | Configurable | Unsupported |
Crate support
** Any unlisted features might be unsupported. **
- Adding quotes around JSON keys:
- Double-quotes: :heavy_check_mark: (default)
- Single-quotes: :white_check_mark:
- Removing quotes around JSON keys:
- Double-quotes: :heavy_check_mark:
- Single-quotes: :heavy_check_mark:
- Supported quotes around JSON string values:
- Double-quotes: :heavy_check_mark:
- Single-quotes: :heavy_check_mark:
- Supports control character escaping in JSON keys:
- Newline (\n): :heavy_check_mark: :white_check_mark:
- Tab (\t): :heavy_check_mark: :white_check_mark:
- Note: These characters could be misinterpreted as not belonging to the key. It is therefore not recommended to start or end a JSON key with these characters.
- Supports control character unescaping in JSON keys:
- Newline (\n): :heavy_check_mark: :white_check_mark:
- Tab (\t): :heavy_check_mark: :white_check_mark:
- Note: These characters could be misinterpreted as not belonging to the key. It is therefore not recommended to start or end a JSON key with these characters.
- Supports control character escaping in JSON string values:
- Newline (\n): :heavy_check_mark: :white_check_mark:
- Tab (\t): :heavy_check_mark: :white_check_mark:
- Supports control character unescaping in JSON string values:
- Newline (\n): :heavy_check_mark: :white_check_mark:
- Tab (\t): :heavy_check_mark: :white_check_mark:
- Supported :heavy_check_mark: characters in JSON keys:
- [A-Z] [a-z] [0-9] ` ~ ! @ # $ % € ^ & * ( ) - _ = + \ | ; " ' . < > / ? \r \n \t \f \v
<U+0020>(Space) - Note: ' and " and their escaped variants could be misinterpreted as keyquotes when used as the last character in a JSON key. It is therefore not recommended to start or end a JSON key with these characters.
- [A-Z] [a-z] [0-9] ` ~ ! @ # $ % € ^ & * ( ) - _ = + \ | ; " ' . < > / ? \r \n \t \f \v
- Supported :heavy_check_mark: characters in JSON values:
- [A-Z] [a-z] [0-9] ` ~ ! @ # $ % € ^ & * ( ) - _ = + \ | : ; " ' . < > / ? \r \n \t \f \v
<U+0020>(Space)
- [A-Z] [a-z] [0-9] ` ~ ! @ # $ % € ^ & * ( ) - _ = + \ | : ; " ' . < > / ? \r \n \t \f \v
Please note that this crate does not check whether the output is valid JSON. The functionality of this crate is based on Regular Expressions and uses the regex crate.
Changelog
- See the changelog.
Contributing
- All contributions are welcome. I will do my best to reply to all questions and PR's.
- Please do note that all contributions made to this crate will be made available using the current license (MIT license).
Third party licenses
- Regex: Copyright (c) 2014 The Rust Project Developers. Licensed under the MIT license, see LICENSES.MIT for details. The notice can be found at Regex-NOTICE. Website: https://github.com/rust-lang/regex.