Getting “System.Collections.Generic.List`1[System.String]” in CSV File export when data is okay on screen

If an object you export as CSV with Export-Csv or ConvertTo-Csv has property values that contain a collection (array) of values, these values are stringified via their .ToString() method, which results in an unhelpful representation, as in the case of your array-valued .IPV4Addresses property. To demonstrate this with the ConvertTo-Csv cmdlet (which works analogously to … Read more

Why does JSON.stringify return empty object notation “{}” for an object that seems to have properties?

JSON.stringify includes an object’s own, enumerable properties (spec) that have values that aren’t functions or undefined (as JSON doesn’t have those), leaving out ones it inherits from its prototype, any that are defined as non-enumerable, and any whose value is a function reference or undefined. So clearly, the object you get back from getVoices()[0] has … Read more

JSON.stringify deep objects

I did what I initially feared I’ll have to do : I took Crockford’s code and modified it for my needs. Now it builds JSON but handles cycles too deep objects too long arrays exceptions (accessors that can’t legally be accessed) In case anybody needs it, I made a GitHub repository : JSON.prune on GitHub … Read more

Convert javascript object or array to json for ajax data

I’m not entirely sure but I think you are probably surprised at how arrays are serialized in JSON. Let’s isolate the problem. Consider following code: var display = Array(); display[0] = “none”; display[1] = “block”; display[2] = “none”; console.log( JSON.stringify(display) ); This will print: [“none”,”block”,”none”] This is how JSON actually serializes array. However what you … Read more