Convert given String to Json Object Javascript -
I have a string like this:
< P> I want to change the JSON object or any other data type to reach every object variable Not given on str = [sa_user {user name = pankaj123, Ughrtaip = Datatreti} Sa_usr {username = data, Ughrtaip = Datatrri} Sa_usr {username = PANKAJ, Ughrtaip = parcel} Sa_usr {username = Devender, Ughrtaip = parcel} Sai_usr {username = Deliharsel, UserType = DataTriter} Sa_user {username = devender, userType = dataentry}, sa_user {username = amit123, userType = dataentry}, sa_user {username = s Anjay, Ussertype = Dataantry} Sa_ugr {username = Mukesh, Ussertype = Dataantry} Sa_ugr {username = test, Ussertype = Dataantry} Sa_ugr {username = Vijayakumar, Ussertype = Dataantry} Sa_ugr {username = Puranl23, Ussertype = Dataantry} , Sa_ugr {username = Snjaykumar, Ussertype = Dataantry} Sa_ugr {username = Nelsonanthony, Ussertype = Dataantry} Sa_ugr {username = draining, Ussertype = Dataantry} Sa_ugr {username = Manoj, Ussertype = parcel} Sa_ugr {username = Ranjit , userType = dataentry}, sa_user {username = DEEPAK, userType = dataentry}, sa_user {username = ASHISH, userType = dataentry}, sa_user {username = Arjun, user type = dataentry}]
username
and User Type
.
, Since the string is not in the valid form of changing the JSON object, how can I use the variable?
You, in parse string, change it to a valid json string and then in javascript you have something like this The need to get the object can:
var myJsonString = ""; // Your Jason String var obj = JSON.parse (myJsonString); Edit: Edit: Put a JSfield together with just one solution, it may be better, but it is done for your specific case.
Comments
Post a Comment