use JsonSerializable
Merge pull request #3228 from anlutro-pull-requests/jsonserialize

[4.2] Implement JsonSerializable