USEPA / useeior

Estimating potential environmental impacts of goods and services in the US economy
MIT License
31 stars 19 forks source link

Write models objects to JSON #294

Open WesIngwersen opened 3 months ago

WesIngwersen commented 3 months ago

JSON files for model objects are already used in useeio.js but they are retrieved from the USEEIO_API.

Alternative is to write JSON objects directly from useeior.

WesIngwersen commented 3 months ago

Currently the following relevant writing is occurring:

  1. Matrices are written to binary in writeModelMatrices Recommend modifying to accept a "json" option for _toformat

  2. Model metadata is written to csv in writeModelMetadata

  3. Model demands are already written to JSON in writeModelDemandstoJSON No changes recommended. The JSON writing here should be used as a template to modify other functions. for instance use jsonlite

  4. The Sector Crosswalk is written to csv in writeSectorCrosswalk Add _toformat parameter with code to handle "json" option

Then create a wrapper function analogous to writeModeltoExcel() but rather it will be writeModeltoJSON()

WesIngwersen commented 3 months ago

to validate the output the resulting JSON needs to be compared to the JSON for a model retrieved from the USEEIO_API via useeio.js or useeio-widgets