JSON is a string. Data (in the way it is used here), is a dictionary.
In many cases, from_json is actually taking a dictionary as an argument named resource_json.
๐ค Expected Behavior
An argument or method referring to json should be working with strings. If it is only working with structured data (that may or may not have once been a string), it should not be referred to as "json".
๐ฏ Current Behavior
BaseCollection expects resouce_class.from_json to exist.
Most (all?) implementations of BaseResource have a classmethod from_json that calls BaseResource.from_data. Note that there is no conversion of string to dict between the two calls.
๐ Possible Solution
I'm fairly certain that all from_json methods can be removed, and calls to them can be changed to from_data (which is already a @classmethod, and so cls will be set to the subclass that it is invoked upon, without that subclass explicitly redefining from_data)
๐ bug report
JSON is a string. Data (in the way it is used here), is a dictionary.
In many cases,
from_json
is actually taking a dictionary as an argument namedresource_json
.๐ค Expected Behavior
An argument or method referring to
json
should be working with strings. If it is only working with structured data (that may or may not have once been a string), it should not be referred to as "json".๐ฏ Current Behavior
resouce_class.from_json
to exist.from_json
that callsBaseResource.from_data
. Note that there is no conversion of string to dict between the two calls.๐ Possible Solution
I'm fairly certain that all
from_json
methods can be removed, and calls to them can be changed tofrom_data
(which is already a@classmethod
, and socls
will be set to the subclass that it is invoked upon, without that subclass explicitly redefiningfrom_data
)๐ฆ Context
I got confused.
๐ Your Environment