Skip to main content

Posts

Showing posts from February, 2016

Serlizing JSON polymorphically when type field is in parent JSON using Jackson

Today, I came across a json parsing situation where the sub-type field is outside the type json. Genrally we seen a situation like this @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class") class Animal{} class Dog extends Animal{ } class Cat extends Animal{ } and it de-serialize to json like this: {      "@class" : "x.y.z.Cat", ... } In my project I need to parse json like this { "status": "OK", "messageName": "x.y.z.Success", "messagePayload": { "foo": "cd3a5697", "bar": 224 } } { "status": "ERROR", "messageName": "x.y.z.Error", "messagePayload": { "errorCode": "APPLICATION_ERROR", "errorInstanceId": "b292b864", "errorDetailedMessage": "Invalid UUID string (Length mismatch)" } }

My first C program: now and then

I was searching for some documents in gmail and found a mail that I sent to company X for their hiring process. It was a c program for searching word in file. I do not know how much time I have taken for it but it was basic search utility function. The point of this blog is not discuss that program but to discuss how time makes you better programmer. Here are the few things I would like to share myself - It takes some learning to write clean code.  Reed books like clean code. You need mentor to learn from his experience. Get a github account and see how experts are writing code. This is not the complete list, there are many things you will acquire over a period of time which make you better programmer. PS: If you are wondering how that program used to look like, then see this  repo.