ObjectId.fromJson constructor
ObjectId.fromJson(
- String json
Creates ObjectId from a JSON string.
This is a factory constructor that maps JSON data to an ObjectId instance.
Example usage:
final jsonString = '{"_id": "507f1f77bcf86cd799439011"}';
final json = jsonDecode(jsonString);
final ObjectId objectId = ObjectId.fromJson(json['_id']);
print(objectId.hexString); // Output: 507f1f77bcf86cd799439011
Note: This method is functionally equivalent to ObjectId.fromHexString. It serves as an alias to clearly indicate the intention to deserialize from a JSON value.
Implementation
factory ObjectId.fromJson(String json) = ObjectId.fromHexString;