Reputation: 2852
I tried following code.
<script>
var empId = 5;
var selected = {};
selected.empId = true;
console.log(JSON.stringify(selected));
</script>
and I got the following result
{"empId":true}
But I need to show it like {"5":"true"}
. How can I do that?
Upvotes: 0
Views: 83
Reputation: 190907
Try using the indexer operator
selected[empId] = true;
To make true
a string, just use a string.
Upvotes: 2