To access a JSON key containing a hyphen, you can use either dot notation or bracket notation. With dot notation, you simply replace the hyphen with an underscore:
myJsonKey.mySubKey // accessing with dot notation
The above example assumes that the JSON object has a key named "myJsonKey" and a sub-key named "my-sub-key". With dot notation, we replace the hyphen with an underscore:
myJsonKey.my_sub_key // accessing with dot notation
Alternatively, you can use bracket notation and include the key inside quotes:
myJsonKey["my-sub-key"] // accessing with bracket notation
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-04-09 11:00:00 +0000
Seen: 14 times
Last updated: Feb 19 '22
How can I turn a string of characters into a list using R?
What causes a syntax error in a for loop and array in Pine Script?
Investigate the usage of square brackets.
What is the process for constructing a dictionary using two columns from pandas DataFrame?
How can Google calendar events be generated on the server-side using Flutter?
How can the dataframe be transformed into a record list without including brackets?
How can brackets in a filepath be managed when it is passed as a variable in the pipeline in Bash?