Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nanoFramework.Json Serialize/Deserialize does not handle \ correctly #1562

Open
mizady opened this issue Dec 8, 2024 · 0 comments · May be fixed by nanoframework/nanoFramework.Json#361
Open

Comments

@mizady
Copy link

mizady commented Dec 8, 2024

Library/API/IoT binding

nanoFramework.Json

Visual Studio version

VS2022 (17.12.2)

.NET nanoFramework extension version

No response

Target name(s)

No response

Firmware version

No response

Device capabilities

No response

Description

nanoFramework.Json.JsonConvert does not properly deserialize the \ character whether an escaped version of string is used or otherwise.

How to reproduce

`public class TestObject
{
public string Value { get; set; }
}

string serializedTestObject = JsonConvert.SerializeObject(new TestObject() { Value = "I:\NanoApp\NFTestApp1.pe" });
TestObject deserializedTestObject = (TestObject)JsonConvert.DeserializeObject(serializedTestObject, typeof(TestObject));`

Expected behaviour

JsonConvert.SerializeObject(new TestObject() { Value = "I:\\NanoApp\\NFTestApp1.pe" });
Results in: {"Value":"I:\NanoApp\NFTestApp1.pe"}
But should be: {"Value":"I:\\NanoApp\\NFTestApp1.pe"}

and when deserializing
TestObject deserializedTestObject = (TestObject)JsonConvert.DeserializeObject(serializedTestObject, typeof(TestObject));
Results in: Exception:nanoFramework.Json.DeserializationException: Exception was thrown: nanoFramework.Json.DeserializationException
But should be: I:\NanoApp\NFTestApp1.pe

The exception also happens if feeding in the json string of {"Value":"I:\\NanoApp\\NFTestApp1.pe"}

Screenshots

No response

Sample project or code

No response

Aditional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant