Retrieving JSON Object Literal from HttpServletRequest

are you looking for this ? @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { StringBuilder sb = new StringBuilder(); BufferedReader reader = request.getReader(); try { String line; while ((line = reader.readLine()) != null) { sb.append(line).append(‘\n’); } } finally { reader.close(); } System.out.println(sb.toString()); }

How to rename JSON key

Parse the JSON const arr = JSON.parse(json); For each object in the JSON, rename the key: obj.id = obj._id; delete obj._id; Stringify the result All together: function renameKey ( obj, oldKey, newKey ) { obj[newKey] = obj[oldKey]; delete obj[oldKey]; } const json = ` [ { “_id”:”5078c3a803ff4197dc81fbfb”, “email”:”[email protected]”, “image”:”some_image_url”, “name”:”Name 1″ }, { “_id”:”5078c3a803ff4197dc81fbfc”, “email”:”[email protected]”, … Read more

How can I pretty-print JSON using node.js?

JSON.stringify‘s third parameter defines white-space insertion for pretty-printing. It can be a string or a number (number of spaces). Node can write to your filesystem with fs. Example: var fs = require(‘fs’); fs.writeFile(‘test.json’, JSON.stringify({ a:1, b:2, c:3 }, null, 4)); /* test.json: { “a”: 1, “b”: 2, “c”: 3, } */ See the JSON.stringify() docs … Read more

Iterating through a JSON file PowerShell

PowerShell 3.0+ In PowerShell 3.0 and higher (see: Determine installed PowerShell version) you can use the ConvertFrom-Json cmdlet to convert a JSON string into a PowerShell data structure. That’s convenient and unfortunate at the same time – convenient, because it’s very easy to consume JSON, unfortunate because ConvertFrom-Json gives you PSCustomObjects, and they are hard … Read more

No serializer found for class org.hibernate.proxy.pojo.javassist.Javassist?

I had a similar problem with lazy loading via the hibernate proxy object. Got around it by annotating the class having lazy loaded private properties with: @JsonIgnoreProperties({“hibernateLazyInitializer”, “handler”}) I assume you can add the properties on your proxy object that breaks the JSON serialization to that annotation. The problem is that entities are loaded lazily … Read more

How do I exclude fields with Jackson not using annotations?

The below example of excluding fields by name is from my blog post, Gson v Jackson – Part 4. (Search for the PropertyFilterMixIn.) This example demonstrates using a FilterProvider with a SimpleBeanPropertyFilter to serializeAllExcept a user-specified list of field names. @JsonFilter(“filter properties by name”) class PropertyFilterMixIn {} class Bar { public String id = “42”; … Read more

Reading in a JSON File Using Swift

Follow the below code : if let path = NSBundle.mainBundle().pathForResource(“test”, ofType: “json”) { if let jsonData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil) { if let jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(jsonData, options: NSJSONReadingOptions.MutableContainers, error: nil) as? NSDictionary { if let persons : NSArray = jsonResult[“person”] as? NSArray { // Do stuff } } } } The … Read more

How to send a POST request with BODY in swift

If you are using Alamofire v4.0+ then the accepted answer would look like this: let parameters: [String: Any] = [ “IdQuiz” : 102, “IdUser” : “iosclient”, “User” : “iosclient”, “List”: [ [ “IdQuestion” : 5, “IdProposition”: 2, “Time” : 32 ], [ “IdQuestion” : 4, “IdProposition”: 3, “Time” : 9 ] ] ] Alamofire.request(“http://myserver.com”, method: … Read more