Skip to content

vm.writeJson should also be able to add new keys  #7232

@wottpal

Description

@wottpal

Component

Forge

Describe the feature you would like

Currently, vm.writeJson is only able to update existing keys which makes it really cumbersome to use when deploying new contracts for the first time and printing them to a file. Instead, it should be able to add new key & value pairs with it, too.

It should also be possible to add nested keys where the parent(s) aren't existing yet as well.

Or at least, the docs should be updated with an easy example on how to add a new (nested) key to an existing JSON file.

From the docs:

This is useful to replace some values in a JSON file without having to first parse and then reserialize it. Note that the JSON path must indicate an existing key, so it’s not possible to add new keys this way.

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Completed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions