title: Is there any way to convert a Map to a JSON representation using Jackson without writing to a file?
body: <p>I'm trying to use Jackson to convert a HashMap to a JSON representation.</p>
  
  <p>However, all the ways I've seen involve writing to a file and then reading it back, which seems really inefficient. I was wondering if there was anyway to do it directly? </p>
  
  <p>Here's an example of an instance where I'd like to do it</p>
  
  <pre><code>public static Party readOneParty(String partyName) {
    Party localParty = new Party();
    if(connection==null) {
      connection = new DBConnection();
    } try {
      String query = "SELECT * FROM PureServlet WHERE PARTY_NAME=?";
      ps = con.prepareStatement(query);
      ps.setString(1, partyName);
      resultSet = ps.executeQuery();
      meta = resultSet.getMetaData();
      String columnName, value;
      resultSet.next();
      for(int j=1;j&lt;=meta.getColumnCount();j++) { // necessary to start at j=1 because of MySQL index starting at 1
        columnName = meta.getColumnLabel(j);
        value = resultSet.getString(columnName);
        localParty.getPartyInfo().put(columnName, value); // this is the hashmap within the party that keeps track of the individual values. The column Name = label, value is the value
      }
    }
  }
  
  public class Party {
  
    HashMap &lt;String,String&gt; partyInfo = new HashMap&lt;String,String&gt;();
  
    public HashMap&lt;String,String&gt; getPartyInfo() throws Exception {
      return partyInfo;
    }
  }
  </code></pre>
  
  <p>The output would look something like this</p>
  
  <pre><code>"partyInfo": {
    "PARTY_NAME": "VSN",
    "PARTY_ID": "92716518",
    "PARTY_NUMBER": "92716518"
  }
  </code></pre>
  
  <p>So far every example I've come across of using <code>ObjectMapper</code> involves writing to a file and then reading it back. </p>
  
  <p>Is there a Jackson version of Java's <code>HashMap</code> or <code>Map</code> that'll work in a similar way to what I have implemented?</p>