I have a string containing comma separated names and optional values that seprated values like this:
var str = "PowerOn:On,ValidLocation, temp:25";
I want to convert it into objects or json that can access to values by name like this:
var a = {"PowerOn":"On", "ValidLocation":"true", "temp":25};
var result = a.PowerOn;
alert(result);
OR
var a = {"PowerOn":"On", "ValidLocation":"true", "temp":25};
var result = a["PowerOn"];
alert(result);
Note 1: If a name doesn't have value it be true by default.
Update:
Note 2 :If a name doesn't exist in list the value of it be false: ex:
var a = {"PowerOn":"On", "ValidLocation":"true", "temp":25};
var result = a.Alarm
//result must be false