title: How do I attach the enum value to an object, instead of the enum name?
body: <p>So my title is probably not the best one, but I think I can better show it in code what I want to achieve. I'm doing things with Spring Boot, JPA and React.</p>
  <p>So let's say I have this enum:</p>
  <pre class="lang-java prettyprint-override"><code>public enum MyEnum {
    FIRST_ENUM(&quot;First&quot;),
    SECOND_ENUM(&quot;Second&quot;)
  }
  </code></pre>
  <p>And there's a class that contains one of the enums:</p>
  <pre class="lang-java prettyprint-override"><code>public class MyClass {
    private int id;
    private MyEnum myEnum;
  }
  </code></pre>
  <p>When I convert an instance of this class to JSON (so I can pass it to React as JSON), this is what I get:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;id&quot;: 1,
    &quot;myEnum&quot;: &quot;FIRST_ENUM&quot;
  }
  </code></pre>
  <p>But instead I want it to use the value instead (I know I can manually create JSONObject instances, but is there a way to automatically use the value instead?):</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;id&quot;: 1,
    &quot;myEnum&quot;: &quot;First&quot;
  }
  </code></pre>