title: Mapping a JSON const in React.js
body: <p>I have a bunch of configurations in a <code>const</code> in my React.js app and the JSON looks like this:</p>
  
  <pre><code>const original = [
    { 'id': '1', 'desc': 'AAA', 'isOK': true },
    { 'id': '2', 'desc': 'BBB', 'isOK': true },
    { 'id': '3', 'desc': 'CCC', 'isOK': false },
    ...
  ];
  </code></pre>
  
  <p>It contains a bunch of configurations that I'll likely put in a separate file somewhere, but for now I wanted to test it and thought that a <code>const</code> would be appropriate.</p>
  
  <p>I'm attempting to use the <a href="https://opensource.appbase.io/reactivesearch/" rel="nofollow noreferrer">ReactiveSearch</a> component and feed this to <a href="https://opensource.appbase.io/reactive-manual/list-components/multidatalist.html" rel="nofollow noreferrer"><code>MultiDataList</code>'s <code>data</code> field</a> for which it needs to be transformed into:</p>
  
  <pre><code>[
    { label: '1', value: 'AAA' },
    { label: '2', value: 'BBB' },
    { value: '3', value: 'CCC' },
    ...
  ]
  </code></pre>
  
  <p>I had assumed that <code>original.map(e =&gt; { 'label': e.id, 'value': e.desc })</code> would do the trick but I get that 'Unexpected token' at the first colon. IntelliJ says 'Expression statement is not assignment or call'.</p>
  
  <p>Mapping through the array with individual items works just fine, e.g. <code>original.map(e =&gt; e.id)</code>, so I am not quite sure what I'm doing wrong. I've only started tinkering with JavaScript and React.js.</p>