-4

The site is on wordpress and I want to use the API via json. There is a true/false result and it manifests itself this way (true or false). How can I display it on the page online/offline? online - when the result is true offline - when the result is false

json

{"online": true}
  • 1
    Does this answer your question? [How do you use the ? : (conditional) operator in JavaScript?](https://stackoverflow.com/questions/6259982/how-do-you-use-the-conditional-operator-in-javascript) – pilchard Jul 19 '22 at 07:42

1 Answers1

0

 var dataParse = `{ "data" : [
      { "label": "guyName", "value": "offline"}
            ]}`;  
              
    var data = JSON.parse(dataParse);
    data.data[0].value = "online"
    dataParse = JSON.stringify(data);

console.log(dataParse);

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify