[Mono-bugs] [Bug 674461] New: System.Json.JsonObject.Save emits invalid JSON
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Feb 23 15:01:50 EST 2011
https://bugzilla.novell.com/show_bug.cgi?id=674461
https://bugzilla.novell.com/show_bug.cgi?id=674461#c0
Summary: System.Json.JsonObject.Save emits invalid JSON
Classification: Mono
Product: Mono: Class Libraries
Version: 2.8.x
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: Daniel.Regner at DirectSupply.com
QAContact: mono-bugs at lists.ximian.com
Found By: Development
Blocker: ---
The implementation of the Save(Stream) method in System.Json.JsonObject does
not conform to the JSON specification at JSON.org nor the Microsoft
implementation of the same method.
Specifically, within key/value pairs, commas are emitted as the delimiter
between the key and the value where colons should be used. Furthermore, no
delimiter is emitted between key/value pairs, which is where the commas should
go.
Source:
https://github.com/mono/mono/blob/master/mcs/class/System.Json/System.Json/JsonObject.cs
Steps to reproduce the problem:
1. Run the below test program.
2. Verify that the expected results do not match the actual results.
Actual Results:
{"key1", "value1""key2", "value2"}
Expected Results:
{"key1": "value1", "key2": "value2"}
How often does this happen?
Always.
Test Program:
using System;
using System.Diagnostics;
using System.IO;
using System.Json;
internal class MainClass
{
private const string _expectedResult = "{\"key1\": \"value1\", \"key2\":
\"value2\"}";
private static void Main()
{
Console.WriteLine("Expected result: " + _expectedResult);
var json = new JsonObject();
json.Add("key1", "value1");
json.Add("key2", "value2");
using (var ms = new MemoryStream())
{
json.Save(ms);
ms.Seek(0, SeekOrigin.Begin);
var actualResult = new StreamReader(ms).ReadToEnd();
Console.WriteLine("Actual result: " + actualResult);
Trace.Assert(actualResult == _expectedResult, "Test case failed.");
}
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list