Here you can find the source of mapToJsonObjectBuilder(Map
public static JsonObjectBuilder mapToJsonObjectBuilder(Map<String, String> map)
//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; } }