CouchDB outputs JSON strings with internal properties such as the document ID and revision prefixed with an underscore. Furthermore, the revision property's value will always contain a hyphen, as CouchDB revisions are in the form "<revision number>-<hex string>". The following JSON string is an example document from CouchDB.
ConvertFrom-JSON does not allow underscores or hyphens to appear in property names or values, whilst ConvertTo-JSON is more lenient and will appear to correctly parse anything that is thrown at it. The attached patch file resolves this issue for ConvertFrom-JSON.
It appears from the JSON specification (http://www.json.org/
) that property names and values can be made up of any Unicode character excluding control characters, " (double-quotes) and \ (backslash). Having attempted to implement this myself, this is mostly trivial; however, correctly handling the escape characters require some lookahead to be built into the parser.