title: How do I add characters to the beginning of each collapsed result of paste0?
body: <p>I'm trying to construct the input json input for mongodb query.</p>
  <p>I have a vector that contains ids</p>
  <pre><code>[1] &quot;62708dc95baeeff0a37571ab&quot; &quot;62708dc95baeeff0a37571ac&quot;
  </code></pre>
  <p>I want to create a JSON object that looks like this:</p>
  <pre><code>[1] [{\&quot;oid\&quot;:\&quot;62708dc95baeeff0a37571ab&quot;},{\&quot;oid\&quot;:\&quot;62708dc95baeeff0a37571ab&quot;}]
  </code></pre>
  <p>so far I have been only able to do this:</p>
  <pre><code>[&quot;{\&quot;oid\&quot;:\&quot;62708dc95baeeff0a37571ab,62708dc95baeeff0a37571ac\&quot;}&quot;]
  </code></pre>
  <p>using this line of code:</p>
  <pre><code>sprintf('{&quot;oid&quot;:&quot;%s&quot;}', paste0(doc_list, collapse=&quot;,&quot;)) %&gt;% jsonlite::toJSON()
  </code></pre>