Abstract
Converts the Data
object into a plain JSON representation, including all
properties defined as getters in the subclass.
The toJSON
method dynamically identifies getter properties in the
subclass and collects their values to construct a JSON object. This is
particularly useful when you want to serialize the Data
object for APIs,
logging, or other use cases requiring JSON format.
A plain object representing the Data
instance with all getter properties.
class LoginData extends Data<FormParser> {
get username() {
return this.parser.getString("username");
}
get password() {
return this.parser.getString("password");
}
}
const loginData = new LoginData(new FormParser(formData));
console.log(JSON.stringify(loginData.toJSON()));
// Output: { "username": "johndoe", "password": "secret" }
Static
fromStatic
from
A table entity represents a single row in a database table.
Table entities are backed by a database table, and are typically used to represent domain objects that are persisted to the database.