Skip to content

.ToString() for JSONNode string keys returns quoted strings #47

@flberger-work

Description

@flberger-work

When doing node["somekey"].ToString() on a JSONNode where the value is already a string, the string is returned wrapped into double quotes, so .ToString() currently returns a literal "abc" instead of an expected abc string.

That happens in WriteToStringBuilder() of class JSONString, that explicitly does

aSB.Append('\"').Append(Escape(m_Data)).Append('\"');

Is there a rationale for this? I was using .ToString() as an easy way to make sure to get a string representation, no matter what the actualy type may have been. However, the unexpected quotes lead to errors e.g. in comparing with expected values, or further parsing the string, so I find myself .Trim()ing them away.

Actual behaviour: string values are returned wrapped in quotes.

Expected behaviour: the string should be returned without quotes.

Thanks for considering.

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