visidata icon indicating copy to clipboard operation
visidata copied to clipboard

[json-] load objects as AttrDict consistently

Open midichef opened this issue 4 months ago • 0 comments

When the JSON loader creates rows in the typical case, by json.load(), they are dict. But any new rows made by addRow() are AttrDict.

To demonstrate: echo '[\n{"n":2}]' |vd -f json then add a row witha. ^Y on the first row shows it is a dict, but on the second row it shows AttrDict.

Similarly, if the file can be loaded as rows of standalone JSON objects, each row is AttrDict: echo '{"n":2}' |vd -f json ^Y shows the row is an AttrDict.

This PR makes the rows all AttrDict, by making the json.load() match the existing call to json.loads().

midichef avatar Feb 17 '24 05:02 midichef