Appending a key value pair to a json object

后端 未结 4 1973
挽巷
挽巷 2020-12-16 00:48

This is the json object I am working with

{
    \"name\": \"John Smith\",
    \"age\": 32,
    \"employed\": true,
    \"address\": {
              


        
4条回答
  •  北海茫月
    2020-12-16 01:45

    Just convert the JSON string to an object using JSON.parse() and then add the property. If you need it back into a string, do JSON.stringify().

    BTW, there's no such thing as a JSON object. There are objects, and there are JSON strings that represent those objects.

提交回复
热议问题