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

Edited Unassigned: Bug: JSON.Decode -> modify object -> Encode.. ignores the array value [1574]

$
0
0
Consider the following code:

```c#
dynamic dObj = System.Web.Helpers.Json.Decode ( contentsOfJsonFile );

// where:

dObj.title // is a flat string
dObj.description // is a flat string
dObj.tags // is an array! ["videos", "pictures", "other assets"]
```

Now, if we access dObj.tags[0] it returns string value. But if we do:

```c#
Json.Encode( dObj )
```

it will convert the object back to JSON string, except the arrays (tags). Apparently, there is a BUG with nested array scenario.

In other words:

```c#
jsonString != Encode( Decode( jsonString ) )
```

*where at atleast one field of JSON has array value.*

For instance, after decoding, encoding this object:

```json
{
"version":3,
"file":"respond.min.js",
"lineCount":1,
"mappings":"CAAM",
"sources":["respond.js"],
"names":["window","matchMedia","doc","bool","docElem"]
}
```

the values of "sources" and "names" will be lost by `Encode()`.

The same works with JSON.NET (third party newtonking library).

Please fix this issue with the native `System.Web.Helpers.Json.Encode()` method.

Thank you.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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