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
Functions called via API internally use the gno.land/p/demo/json package to generate JSON. This package operates by directly adding required fields to json.Node objects when creating JSON and then encoding them.
Looking at the current JSON generation approach in our codebase, since required fields are called and generagted within each function as needed, there is a lot of redundancy and many sections with poor readability and maintainability. In my opinition, it would better align with this package's intended usage to create functions that generate json.Node for each type and then assemble them using the builder pattern (supported by the package as json.Builder).
Additionally, there are cases where numeric and boolean values are converted to strings, before output during JSON generation. We could reduce unnecessary operations by outputting these values in their original types without conversion.
Furthermore, when comparing JSON output values in tests, we're currently using direct string comparison, which significantly reduces test maintainability. This issue can be resolved by using the methods provides by JSON package (refer to the `json/nodes.gno file).
Description
Functions called via API internally use the
gno.land/p/demo/json
package to generate JSON. This package operates by directly adding required fields tojson.Node
objects when creating JSON and then encoding them.Looking at the current JSON generation approach in our codebase, since required fields are called and generagted within each function as needed, there is a lot of redundancy and many sections with poor readability and maintainability. In my opinition, it would better align with this package's intended usage to create functions that generate
json.Node
for each type and then assemble them using the builder pattern (supported by the package asjson.Builder
).Additionally, there are cases where numeric and boolean values are converted to strings, before output during JSON generation. We could reduce unnecessary operations by outputting these values in their original types without conversion.
Furthermore, when comparing JSON output values in tests, we're currently using direct string comparison, which significantly reduces test maintainability. This issue can be resolved by using the methods provides by JSON package (refer to the `json/nodes.gno file).
Prior Arts
The text was updated successfully, but these errors were encountered: