Added methods toJson(), fromJson(). Fixed  fromArray()