Reputation: 487
The Plaid API returns data in a format that is similar to but not quite JSON. For example a (sandboxed, not real data) query for "accounts" returns
{'account_id': 'xllNjaMoAoCPvNVLAN89t1WaL1KXZxsn56pqb',
'balances': {'available': 100.0,
'current': 110.0,
'iso_currency_code': 'USD',
'limit': None,
'unofficial_currency_code': None},
'mask': '0000',
'name': 'Plaid Checking',
'official_name': 'Plaid Gold Standard 0% Interest Checking',
'subtype': 'checking',
'type': 'depository'}
This is typed "AccountBase" (or similarly named alternatives for items and transactions). In their demo code for Python they presume the use of the Flask jsonify()
command, but I'm not using Flask. From the shell, jsonpickle.encode()
works, but it doesn't work within PHP for reasons that are beyond me. json.dumps()
won't attempt to convert AccountBase.
AccountBase objects do print() neatly, but the result is a string which can not be converted into JSON in any useful way.
I ask the community — how might one convert an AccountBase (or ItemBase, or TransactionBase) object into JSON?
Upvotes: 0
Views: 208
Reputation: 487
It's not a noble answer, but I eventually gave up and installed the jsonpickle library with sudo pip3
instead of pip3
, and that seems to have solved it.
Upvotes: 1