8000 Inconsistent Quoting Behavior in String Serialization · Issue #397 · dtolnay/serde-yaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
Inconsistent Quoting Behavior in String Serialization #397
Open
@NanezX

Description

@NanezX

Issue Description:

When using serde_yaml for deserialization, strings within YAML files lose their quotes (which we can tell is ok). However, during serialization, manually adding quotes to a string results in unexpected behavior, with extra quotes being added. This inconsistency poses challenges when working with YAML files that require specific quoting, leading to malformed output.

Steps to Reproduce:

Deserialize a YAML file containing quoted strings.
Change a string value and attempt to serialize it back.
Observe the unexpected behavior in the serialized output.

Expected Behavior:

During serialization, there should be a way to explicitly specify whether quotes should be added to a string, and this behavior should be consistent with manual addition of quotes.

Actual Behavior:

Serialization adds extra quotes or behaves inconsistently when attempting to preserve quotes around strings.

Example:

specVersion: 0.0.4
schema:
  file: ./schema.graphql
address: "0x0000000000000000000000000000000000000000"

When the deserialziation is made, I'll get an string of address without quotes. Let's say I want to change the address to 0xffaed20B7B67e498A3bEEf97386ec1849EFeE6Ac, so I use that value as string. The output will add address without quotes.

But if I use '0xffaed20B7B67e498A3bEEf97386ec1849EFeE6Ac' (with quotes in the string), the serialization will add three single quotes, so the output will be:

specVersion: 0.0.4
schema:
  file: ./schema.graphql
address: '''0xffaed20B7B67e498A3bEEf97386ec1849EFeE6Ac'''

On the other hand, if I use doublue quotes when adding the string, the output will be:

specVersion: 0.0.4
schema:
  file: ./schema.graphql
address: '"0xffaed20B7B67e498A3bEEf97386ec1849EFeE6Ac"'

How I should handle this? is an issue? is on purpose? how can be fixed?

Environment:

serde version: 1.0.192
serde_yaml version: 0.9.27
Rust version: rustc 1.73.0
Operating System: Ubuntu 22.04 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0