Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Unassigned: Format JSON document and Adding comments [1611]

$
0
0
Please also add the support to encode the **Formatted / Readable** JSON document; perhaps by adding a second parameter to `JSON.Encode`? Preferably, [Minify = false] (overloaded method to avoid CA warning 8-)).

See this hack; [madskristensen/WebEssentials2013#466](https://github.com/madskristensen/WebEssentials2013/commit/9c38d3331a29fe88a878b5f4fb70e18cf57c8ab1#diff-2d6f278dcf0ab21920e17fd38cdf4232R128) we had to use Newtonsoft's `Parse()` function (unwanted overhead), in addition to JSON.Encode. I personally prefer System.Web.Helpers.JSON over JSON.NET.

On the same note, please give us ability to write comments.

For dynamic objects:

```c#
dynamic myObject = JSON.Decode(File.ReadX("myFile"));
myObject.someProperty.InlineComment = "This comment appears as inline. This is deprecated, but masses still use it";
myObject.someOtherProperty.Comment = "This is a standard multi-line comment appears";
```

should result in:

```Json
someProperty : "value"; // This comment appears as inline. This is deprecated, but masses still use it
/* This is a standard multi-line comment appears */
someOther Property : "value";
```

For non-dynamic object, the attribute:

```c#
internal class SpriteMapConstituent
{
public string Name { get; set; }
public int Width { get; set; }
public int Height { get; set; }
[InlineComment = "X Coordinate offset"]
public int OffsetX { get; set; }
[Comment = "Y Coordinate offset"]
public int OffsetY { get; set; }
}
```

should result in:

```Json
{
Name: "file.png",
Width: 200,
Height: 350,
OffsetX: 20, // X Coordinate offset
/* Y Coordinate offset */
OffsetY: 20
}
```


Thanks in anticipation. 8-)

Comments: This unfortunately falls below our currently prioritized items. We don't plan to extend the JSON helper. We recommend moving new code to json.NET.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>