You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to serialize and deserialize MarketBook objects. I am 1) going from MarketBook to JSON, then 2) JSON back to MarketBook. It appears that when converting JSON to MarketBook, the marketDefinition does not set itself. With a bit of trial and error, I discovered that I can get a correct MarketBook by setting the key "market_definition" instead of the "marketDefinition" in the JSON outputted from first step.
Assuming an existing, populated MarketBook object as "mb1"
Doesn't work, market_definition is not set:
import json
mb_json = mb1.json()
mb_dict = json.loads(mb_json)
new_mb = MarketBook(**mb_dict)
# new_mb.market_definition is None at this point.
I am trying to serialize and deserialize MarketBook objects. I am 1) going from MarketBook to JSON, then 2) JSON back to MarketBook. It appears that when converting JSON to MarketBook, the marketDefinition does not set itself. With a bit of trial and error, I discovered that I can get a correct MarketBook by setting the key "market_definition" instead of the "marketDefinition" in the JSON outputted from first step.
Assuming an existing, populated MarketBook object as "mb1"
Doesn't work, market_definition is not set:
Works, market_definition is set:
If this isn't how I should be storing MarketBooks, I'd be more than happy to be corrected :-)
The text was updated successfully, but these errors were encountered: