-1

Need to create an object from the given variable string.

var text ='{"Origin":"Hybris","country":"Germany","Email":"senthilkumar@yopmail.com","Businesstype": "Global","region": "EMEA", "lang": "en_US}"}'
AyushKatiyar
  • 1,000
  • 8
  • 15
  • 3
    Is the text correctly pasted? – Rinkesh Golwala Jul 10 '20 at 18:15
  • 2
    Does this answer your question? [Converting a string to JSON object](https://stackoverflow.com/questions/10976897/converting-a-string-to-json-object) – Sphinx Jul 10 '20 at 18:16
  • You should utilize the code snippet feature in the editor to better display your code. It will show formatting and could can help others to see issue. – nihiser Jul 10 '20 at 18:49

2 Answers2

3

I hope this helps

let text = '{"Origin":"Hybris","country":"Germany","Email":"senthilkumar@yopmail.com","Businesstype":"Global","region":"EMEA","lang":"en_US"}';

let json = JSON.parse(text);
console.log(json);
sonEtLumiere
  • 4,461
  • 3
  • 8
  • 35
1

JSON.parse(string) Parses the string into the javascript object and JSON.stringify(obj) Converts the Javascript object into String. In your scenario JSON.parse would do the job. Try using:

let text = '{"Origin":"Hybris","country":"Germany","Email":"senthilkumar@yopmail.com","Businesstype":"Global","region":"EMEA","lang":"en_US"}';
let json = JSON.parse(text);
console.log(json);

Hope this helps.

AyushKatiyar
  • 1,000
  • 8
  • 15