How to edit a .json file?

graemebargengraemebargen Member Posts: 9


I have a specific .json file i would like to amend, specifically I would like to add a value to the end of a matrix (1 column, 20 rows) that is saved in the .json file. The name of the matrix is initial_params. Is there a short script that can be written to simply add one value to the end of the matrix (eg. to add a value to the 21st row)?



  • kjohnsonkjohnson Posts: 172Ansys Employee

    Hello @graemebargen ,

    The simplest way to edit a JSON file would be to use a text editor. If you want to automate the process, the Lumerical scripting language has some commands for working with JSON files with specific formats:

    What's the format of the JSON file? If it is a custom JSON file that isn't in the format used by the Lumerical scripting language I think you will have to use general string manipulation techniques, as in reading in the data from the text file with the read command, creating new strings, and adding them to the JSON file with the write command.

Sign In or Register to comment.