Skip to content

Commit 0068bcf

Browse files
committed
Fixed #94
- Fixed issue with string encoding when using quote characters Signed-off-by: rpgmaker <[email protected]>
1 parent 6813532 commit 0068bcf

File tree

8 files changed

+22
-5
lines changed

8 files changed

+22
-5
lines changed

NetJSON.Tests/SerializeTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,23 @@ public void TestSerializeDateWithMillisecondDefaultFormatLocal() {
254254
var ddate = NetJSON.Deserialize<DateTime>(djson);
255255
Assert.IsTrue(date == ddate);
256256
}
257+
258+
[TestMethod]
259+
public void TestSerializeDictionaryWithComplexDictionaryString() {
260+
NetJSON.IncludeFields = true;
261+
Dictionary<string, string> sub1 = new Dictionary<string, string> { { "k1", "v1\"well" }, { "k2", "v2\"alsogood" } };
262+
var sub1Json = NetJSON.Serialize(sub1);
263+
Dictionary<string, string> main = new Dictionary<string, string> {
264+
{ "MK1", sub1Json },
265+
{ "MK2", sub1Json } };
266+
267+
//At this moment we got in dictionary 2 keys with string values. Every string value is complex and actually is the other serialized Dictionary
268+
string final = NetJSON.Serialize(main);
269+
270+
//Trying to get main dictionary back and it fails
271+
var l1 = NetJSON.Deserialize<Dictionary<string, string>>(final);
272+
Assert.IsTrue(l1.Count == 2);
273+
}
257274

258275
[TestMethod]
259276
public void TestSerializeDateUtcNowWithMillisecondDefaultFormatUtc() {
0 Bytes
Binary file not shown.

NetJSON.v12.suo

0 Bytes
Binary file not shown.

NetJSON/NetJSON.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@ public static unsafe void EncodedJSONString(StringBuilder sb, string str) {
15701570
sb.Append("\\\"");
15711571
else if (quote == '\'')
15721572
sb.Append("\\\'");
1573-
}
1574-
sb.Append(c);
1573+
} else
1574+
sb.Append(c);
15751575
break;
15761576
}
15771577

NetJSON/NetJSON.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<id>NetJSON</id>
55
<title>NetJSON</title>
66
<tags>json json-serializer javascript JSON serializer binary</tags>
7-
<version>1.0.15.2</version>
7+
<version>1.0.15.3</version>
88
<authors>TJ Bakre</authors>
99
<description>Faster than Any Binary?</description>
1010
<language>en-US</language>

NetJSON/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.15.2")]
36-
[assembly: AssemblyFileVersion("1.0.15.2")]
35+
[assembly: AssemblyVersion("1.0.15.3")]
36+
[assembly: AssemblyFileVersion("1.0.15.3")]

NetJSON/lib/net35/NetJSON.dll

0 Bytes
Binary file not shown.

NetJSON/lib/net40/NetJSON.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)