Java Json mapToJsonObjectBuilder(Map map)

Here you can find the source of mapToJsonObjectBuilder(Map map)

Description

map To Json Object Builder

License

Open Source License

Declaration

public static JsonObjectBuilder mapToJsonObjectBuilder(Map<String, String> map) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

import java.util.Map;
import java.util.Map.Entry;
import javax.json.Json;

import javax.json.JsonObjectBuilder;

public class Main {
    public static JsonObjectBuilder mapToJsonObjectBuilder(Map<String, String> map) {
        JsonObjectBuilder jsonObject = Json.createObjectBuilder();
        if (map == null || map.isEmpty()) {
            return jsonObject;
        }/*  w  w  w .j av a 2 s.  c om*/
        Iterator<Entry<String, String>> i = map.entrySet().iterator();
        while (i.hasNext()) {
            Entry<String, String> e = i.next();
            jsonObject.add(e.getKey(), e.getValue());
        }
        return jsonObject;
    }
}

Related

  1. jsonObjectToBuilder(JsonObject jo)
  2. jsonPrettyPrinter(Object object)
  3. jsonString(JsonValue value)
  4. jsonValueToJsonString(final JsonValue jsonValue, final String key)
  5. listToJsonArray(List list)
  6. newObject()
  7. nullable(String value)
  8. objectToJsonDateSerializer(Object ts, final String dateformat)
  9. printJavaxJsonProvider()