Converts a Result value to a JavaScript object that may be stored as a JSON value.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
type JSONSerialisation = {
  "@@type":  String,
  "@@tag":   String,
  "@@value": Object Any
}
Variant . () => JSONSerialisationConverts a Result value to a JavaScript object that may be stored as a JSON value.
See the docs for adt/union/derivations/serialization for more details.
const Result = require('folktale/result');
Result.Ok(1).toJSON();
// ==> { '@@type': 'folktale:Result', '@@tag': 'Ok', '@@value': { value: 1 } }
Result.Error(1).toJSON();
// ==> { '@@type': 'folktale:Result', '@@tag': 'Error', '@@value': { value: 1 } }
Result.Error(undefined).toJSON();
// ==> { '@@type': 'folktale:Result', '@@tag': 'Error', '@@value': { value: null } }
function() {
    return { 
      [typeJsonKey]:  typeName, 
      [tagJsonKey]:   tagName, 
      [valueJsonKey]: mapValues(this, serializeValue) 
    };
  }