Spring + jsp + selectivity.js - how to read selectivity config from file builded on java site
<p>I am using in my spring app <a href="https://arendjr.github.io/selectivity/" rel="nofollow">selectivity.js</a> which is a selection library with nice "tags look". Right now I have js file where I configure selectivity data:</p>

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>/**
 * 
 */
$(document).ready(
 function() {
  $('#single-input-with-labels').selectivity(
  {
   multiple : true,
   items : 
   [ 
    {
     text : 'City',
     children : [{
      id : 1,
      text : 'cityName1'
     }, {
      id : 2,
      text : 'cityName2'
     }, {
      id : 3,
      text : 'cityName3'
     }]
    }, {
     text : 'Type',
     children : [{
      id : 4,
      text : '2.1.typeName1'
     }, {
      id : 5,
      text : '2.2.typeName2'
     }, {
      id : 6,
      text : '2.3.typeName3'
     }]
    }
   ],
   placeholder : 'ie. City, Type, ...',
   searchInputPlaceholder : 'Type to search'
  });
 }
);</code></pre>
</div>
</div>
</p>

<p>But I need to have this configuration :</p>

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>{
   multiple : true,
   items : 
   [ 
    {
     text : 'City',
     children : [{
      id : 1,
      text : 'cityName1'
     }, {
      id : 2,
      text : 'cityName2'
     }, {
      id : 3,
      text : 'cityName3'
     }]
    }, {
     text : 'Type',
     children : [{
      id : 4,
      text : '2.1.typeName1'
     }, {
      id : 5,
      text : '2.2.typeName2'
     }, {
      id : 6,
      text : '2.3.typeName3'
     }]
    }
   ],
   placeholder : 'ie. City, Type, ...',
   searchInputPlaceholder : 'Type to search'
  }</code></pre>
</div>
</div>
</p>

<p>in some file for example: "myData.txt". I will build this txt file programmatically from java site after analysis of some data. In next step I need to read this structure from the js function :</p>

<p><div class="snippet" data-lang="js" data-hide="true">
<div class="snippet-code snippet-currently-hidden">
<pre class="snippet-code-js lang-js prettyprint-override"><code>/**
 * 
 */
$(document).ready(
 function() {
  $('#single-input-with-labels').selectivity(
          /* here I want to read this structure from the generated txt file
  );
 }
);</code></pre>
</div>
</div>
</p>

<p>Do you know how to read this structure of data from another text file to make it work?</p>