Jayesh Acharya
asked on
dynamically assign key in json using javasctipt
I am trying to find a way to dynamically assign keynames when creating my json object using java script.
This issue I have is that the stringfy option ignores the value for the key name but it does interpet the key value
..
..
var xxKeyName = "MyTestKey1"
var xxKeyValue = "12345"
var oTableDataJson =
JSON.stringify(
{xxKeyName : xxKeyValue});
..
this result in a json looking like:
{"xxKeyName":"12345"}
but what I want is
{"MyTestKey1":"12345"}
This issue I have is that the stringfy option ignores the value for the key name but it does interpet the key value
..
..
var xxKeyName = "MyTestKey1"
var xxKeyValue = "12345"
var oTableDataJson =
JSON.stringify(
{xxKeyName : xxKeyValue});
..
this result in a json looking like:
{"xxKeyName":"12345"}
but what I want is
{"MyTestKey1":"12345"}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window