Attribute names with special characters are modified during JSON parsing and serialization
Summary
When parsing JSON with attributes containing special characters (e.g., [
, ]
, or spaces), the attribute names are modified during serialization, resulting in changes to the original attribute names when the JSON is serialized back.
Steps to reproduce
- Create a JSON object with attribute names containing special characters, such as:
"attribute[1]": "value"
"attribute name with spaces": "value"
"attribute]2[": "value"
- Parse the JSON object into a Python object.
- Serialize the Python object back to JSON.
- Inspect the serialized JSON.
What is the current bug behavior?
- The attribute names with special characters change during the serialization and deserialization process.
- For example, the attribute
"attribute 1"
may be changed to"attribute1"
, causing the original structure to be lost.
What is the expected correct behavior?
- The attribute names containing special characters should remain unchanged during both the parsing and serialization processes.
- The serialized JSON should preserve the original attribute names exactly as they appeared in the input.