Preserve comments when serializing/deserializing with toJSON and fromJSON.#983
Conversation
| function MapField(name, id, keyType, type, options) { | ||
| Field.call(this, name, id, type, options); | ||
| function MapField(name, id, keyType, type, options, comment) { | ||
| Field.call(this, name, id, type, undefined, undefined, options, comment); |
There was a problem hiding this comment.
Please confirm, this looks like an old bug calling base class constructor with wrong params.
There was a problem hiding this comment.
I believe omitting rule and extend and instead passing options should be handled here. Might well be, though, that specifying undefined explicitly is better optimizable by JS engines?
There was a problem hiding this comment.
Ah I didn't see the parameter shuffling in the Field constructor...I think it's clearer to explicitly pass undefined values for these, what do you think? Since options can be undefined here as well, the duck typing in Field() gets a little nondeterministic if these values are omitted.
There was a problem hiding this comment.
Added additional parameter shuffling to handle the comment parameter.
|
Thanks! |
This version has an option controlling toJSON behavior. By default we'll skip comments when serializing to JSON, or they can be preserved by passing the new option. Thanks!