Posts

Showing posts with the label json

Google Auto Value with Jackson Json

 I got a chance to work on a code base which used Google's Auto Value library and Jackson library for serialising and deserialising Json request and response payload. I tried to get the sweet spot with minimal need of annotations from Auto Value and Jackson. The following example shows the bare minimal change need to generate Json payload. It has the flexibility to construct the value object using builder pattern and ability to handle optional fields, collections and change the field name if required. package com.harishkannarao.example; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.google.auto.value.AutoValue; import java.time.OffsetDateTime; import java.util.List; import java.util.Optional; import java.util.UUID; @AutoValue @JsonDeserialize(builder = AutoValue_ExampleModel.Builder.class) public abstract class ExampleModel { ...

Kotlin / Ktor / Jdbi Json / Api / Free Marker / VueJs

Image
About this blog A brief reason for writing this blog. I am a server side http api / web developer predominantly using JVM based languages. Recently I started using Kotlin programming language (developed by JetBrains) with Spring Boot Framework on AWS cloud to build an enterprise solution (including both API and small web portal for internal Admins) to serve data for the mobile apps. I loved Kotlin as a programming language for Server Side development. So I was curious to explore Ktor Framework (developed and sponsored by JetBrains) for Server Side Web Development (API & Webpages). Hence I created a sample repository in Git Hub to play with Ktor Framework to experiment with various enterprise grade features offered by Ktor Framework. Please read this blog in conjuction with my Kotlin repository available at https://github.com/harishkannarao/kotlin High Level Components Diagram API The API development was very very simple with Jackson / Google GSON integration. The...

JSON with curl and jq

This blog post captures some quick commands to deal with JSON from servers (Http APIs) using curl and jq command line tools About Jq: https://stedolan.github.io/jq/ Install jq: Mac: brew install jq Ubuntu or Debian: sudo apt-get install jq Sample JSON content: Assume the following JSON content will be returned from  URL http://api.example.com/some-json-content {     "user_name": "User 123",     "some_other_field": {         "sub_field": "sub_value"     },     "array_field": [         {             "field1": "value1",             "field2": "value2"         },         {             "field1": "value3",             "field2": "value4"         }     ] } UR...