Tags » JSON

How to read JSON with object name using Json.Net in C#

In this article I am going to explain how to read the values from Json using Json.Net library when it is having Object Name. 288 more words


How to handle multi array json data ?

I recently faced issue in handling Multi array Json in for loop. After long R&d I found the following solution


type: ‘GET’, 80 more words

Handling Multi Array Json Array

cross-origin resource sharing

I keep finding myself going over to the Enable CORS website to copy/paste their example code into my server-side.  They’ve saved me more than once. 229 more words

Open Source

PDXPUG: February meeting in two weeks

When: 6-8pm Thursday Feb 18, 2016
Where: Iovation
Who: Jason Owen
What: Incremental Schema Discovery via JSON Wrangling

Over the last few releases, Postgres has added and expanded support for storing and querying JSON documents. 243 more words

Meeting Announcements

Convert Object as Json String using FasterXML/jackson-databind

Please refer the FasterXml/Jackson-bind API from the below GitHub repo. This is very helpful in handling various data format especially JSON


The sample code to convert the Object as json string is given below, 45 more words


Convert Object as Json using FasterXML/jackson-jr

Please refer the FasterXml API from this below GitHub repo. Its an alternative to jackson-bind API for processing JSON.


This provides an easy way to convert the java object to json and vice versa… 24 more words


AWS DynamoDB map object to Base64 encoded gzipped JSON in Java

Annotation in a DynamoDBTable class:
    private Pojo pojo;

public static class PojoMarshaller extends GzipJsonMarshaller<Pojo> { }


import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMarshaller;
import com.fasterxml.jackson.databind.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.IOUtils;

import java.io.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.zip.*;

import static com.amazonaws.util.Throwables.failure;

public class GzipJsonMarshaller<T extends Object> implements DynamoDBMarshaller<T> {

    private static final ObjectMapper mapper = new ObjectMapper();
    private static final ObjectWriter writer = mapper.writer();

    public String marshall(T obj) {
        try {
            String plainJsonString = writer.writeValueAsString(obj);
            byte[] binaryBytes = compressString(plainJsonString).array();
            String base64BinaryString = Base64.encodeBase64String(binaryBytes);
            return base64BinaryString;
        } catch (Exception e) {
            throw failure(e, "Unable to marshall the instance of " + obj.getClass() + "into a string");

    public T unmarshall(Class<T> clazz, String base64BinaryString) {
        try {
            byte[] binaryBytes = Base64.decodeBase64(base64BinaryString);
            String plainJsonString = uncompressString(ByteBuffer.wrap(binaryBytes));
            return mapper.readValue(plainJsonString, clazz);
        } catch (Exception e) {
            throw failure(e, "Unable to unmarshall the string " + base64BinaryString + "into " + clazz);

    public static ByteBuffer compressString(String input) throws IOException {
        ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
        GZIPOutputStream gzipOutput = new GZIPOutputStream(byteArrayOutput);
        byte[] compressedBytes = byteArrayOutput.toByteArray();
        ByteBuffer buffer = ByteBuffer.wrap(compressedBytes);
        return buffer;

    public static String uncompressString(ByteBuffer input) throws IOException {
        byte[] bytes = input.array();
        ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(bytes);
        GZIPInputStream gzipInput = new GZIPInputStream(byteArrayInput);
        ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream();
        IOUtils.copy(gzipInput, byteArrayOutput);
        return new String(byteArrayOutput.toByteArray(), "UTF-8");


Java Programming