Date query with ISODate in mongodb doesn’t seem to work

Although $date is a part of MongoDB Extended JSON and that’s what you get as default with mongoexport, I don’t think you can really use it as a part of the query. If try exact search with $date like below: db.foo.find({dt: {“$date”: “2012-01-01T15:00:00.000Z”}}) you’ll get the error: error: { “$err” : “invalid operator: $date”, “code” … Read more

Convert Dictionary to JSON in Swift

Swift 3.0 With Swift 3, the name of NSJSONSerialization and its methods have changed, according to the Swift API Design Guidelines. let dic = [“2”: “B”, “1”: “A”, “3”: “C”] do { let jsonData = try JSONSerialization.data(withJSONObject: dic, options: .prettyPrinted) // here “jsonData” is the dictionary encoded in JSON data let decoded = try JSONSerialization.jsonObject(with: … Read more

What is deserialize and serialize in JSON?

JSON is a format that encodes objects in a string. Serialization means to convert an object into that string, and deserialization is its inverse operation (convert string -> object). When transmitting data or storing them in a file, the data are required to be byte strings, but complex objects are seldom in this format. Serialization … Read more

How to pass payload via JSON file for curl?

curl sends POST requests with the default content type of application/x-www-form-urlencoded. If you want to send a JSON request, you will have to specify the correct content type header: $ curl -vX POST http://server/api/v1/places.json -d @testplace.json \ –header “Content-Type: application/json” But that will only work if the server accepts json input. The .json at the … Read more

Could not load file or assembly ‘Newtonsoft.Json’ or one of its dependencies. Manifest definition does not match the assembly reference

To solve this, I ensured all my projects used the same version by running the following command and checking the results: update-package Newtonsoft.Json -reinstall And, lastly I removed the following from my web.config: <dependentAssembly> <assemblyIdentity name=”Newtonsoft.Json” publicKeyToken=”30ad4fe6b2a6aeed” culture=”neutral” /> <bindingRedirect oldVersion=”0.0.0.0-6.0.0.0″ newVersion=”6.0.0.0″ /> </dependentAssembly> If you want to ensure all your Newtonsoft.Json packages are the … Read more

How to style a JSON block in Github Wiki?

Some color-syntaxing enrichment can be applied with the following blockcode syntax “`json Here goes your json object definition “` Note: This won’t prettify the json representation. To do so, one can previously rely on an external service such as jsbeautifier.org and paste the prettified result in the wiki.

Is there a query language for JSON?

EDIT Sept 2022: JMESPath seems to be the most widely-used, fastest-growing, and best-reviewed of alternatives for this. It has many features, including “where”-style filters. ORIGINAL: Sure, how about: JsonPath. Json Query They all seem to be a bit work in progress, but work to some degree. They are also similar to XPath and XQuery conceptually; … Read more

How to escape special characters in building a JSON string?

I’m appalled by the presence of highly-upvoted misinformation on such a highly-viewed question about a basic topic. JSON strings cannot be quoted with single quotes. The various versions of the spec (the original by Douglas Crockford, the ECMA version, and the IETF version) all state that strings must be quoted with double quotes. This is … Read more