title: How to produce a json object message into kafka topic using java(spring)?
body: <p>I want to produce a message into kafka topic. That message should have this pattern:</p>
  
  <pre><code>   {"targetFileInfo":{"path":"2018-05-07-10/row01-small-01.txt.ready"}}
  </code></pre>
  
  <p>I know that is a json pattern, so how can i convert that json in String?</p>
  
  <p>I use a maven project, so which dependencies are needed to use  </p>
  
  <pre><code> String stringData = JSON.stringify({"targetFileInfo":{"path":"2018-05-07-10/row01-small-01.txt.ready"}});
  </code></pre>
  
  <p>So I think it is better don't convert Json to string and send indeed that massage into kafka topic. </p>
  
  <p>My Code is like that, it can send a String but i don't know how i can modify my code to send the massage above. maybe you can help me.</p>
  
  <pre><code> Producer&lt;String, String&gt; producer = null;
  
      Properties props = new Properties();
      props.put("bootstrap.servers", "localhost:9092");
      props.put("acks", "all");
      props.put("retries", 0);
      props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
      props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
  
      producer = new KafkaProducer&lt;&gt;(props);
      String msg = "welcome";
      producer.send(new ProducerRecord&lt;String, String&gt;("event", msg));
  
      producer.close();
  </code></pre>