0

One of the JSON field in my JSON file has the field "AlphaWorkStatusChangeInfo-Comment" and I'm trying to add value to that field. But some how the type/JS script is not accepting the "-" in the field.

            let data = JSON.parse(JSON.stringify(Agri.data));
           
            data.AlphaWorkStatusChangeInfo =  ["other"];
            data.AlphaWorkStatusChangeInfo-Comment = "Had to quit the job";
            data.autoSave = true;

What are my options to include/Add the value in the field "AlphaWorkStatusChangeInfo-Comment".

Any help is much appreciated.

Gowtham Ramamoorthy
  • 896
  • 4
  • 15
  • 36

1 Answers1

0

The hyphen is not valid unless you encase it as a string element like so:

data["AlphaWorkStatusChangeInfo-Comment"] = "Had to quit the job";

See here for more discussion on this topic: Which characters are valid/invalid in a JSON key name?

BadHorsie
  • 14,135
  • 30
  • 117
  • 191