title: What is the best way to serialize/deserialize Dart's new enum with JSON?
body: <p>I'd like to make use of Dart's new (experimental) <code>enum</code> feature instead of using stacks of static const Strings, but what's the best way to serialize/deserialize <code>enum</code> variables using JSON? I've made it work this way, but surely there's a better solution:</p>
  
  <pre><code>enum Status {
    none,
    running,
    stopped,
    paused
  }
  
  Status status1 = Status.stopped;
  Status status2 = Status.none;
  
  String json = JSON.encode(status1.index);
  print(json);   // prints 2
  
  int index = JSON.decode(json);
  status2 = Status.values[index];
  print(status2);  // prints Status.stopped
  </code></pre>
  
  <p>If you serialize using the index, you can get locked into keeping your enums in the same order forever, so I'd much prefer to use some kind of String form. Anyone figured this out?</p>