question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method name 'toJSON' should rename as 'toPlain'

See original GitHub issue

File: lib/model.js

  /**
   * Convert the instance to a JSON representation. Proxies to calling `get` with no keys. This means get all values gotten from the DB, and apply all custom getters.
   *
   * @see {@link Model#get}
   * @return {object}
   */
  toJSON() {
    return _.clone(
      this.get({
        plain: true
      })
    );
  }

This method should return a JSON string, that’s make sense, but not a plain Object. Change it’s name to toPlain is better.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
devoto13commented, Apr 4, 2019

toJSON name has a special meaning.

0reactions
s79commented, Apr 5, 2019

You’re right. I misunderstand. Sorry to bother you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I change the property name of a serialized entity ...
With class-transformer , you can change the name of a column with @Expose : @Expose({ name: "name_column" }) name: string;. For the ...
Read more >
Rename refactoring | ReSharper Documentation
This refactoring allows you to change name of any symbol or project in your solution. All references to and usages of the symbol...
Read more >
JSON-LD 1.1
JSON is a useful data serialization and messaging format. This specification defines JSON-LD 1.1, a JSON-based format to serialize Linked ...
Read more >
Renaming an object key #979 - bblanchon/ArduinoJson
Currently, it is not possible to rename an object key efficiently. However, renaming an object key can be handy at times.
Read more >
Serialization | NestJS - A progressive Node.js framework
Serialization is a process that happens before objects are returned in a ... You can use the @Expose() decorator to provide alias names...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found