0

I need to add any new value to the array which is storing a response in JSON.

pict is an array in JS this.pict.push(new Error(JSON.stringify(responseholder)

let me know if i can add new string A and String B in responseholder as field.

1
  • just want to add method name and component name in the JSON object
    – user75850
    Nov 12 '19 at 12:54
2

You just need to add properties to your JSON.

responseholder.methodName = 'methodName';
responseholder.componentName = 'componentName';

So it will look like:

JSON.stringify(responseholder);
{"country":"FR","name":"Lyon","lat":"45.75","lng":"4.583333","methodName":"methodName","componentName":"componentName"}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.