added missing toJson function