Question: In the project, the data format passed from the backend is like this. How do I get the value in BYMONTH?
INTERVAL=8;BYMONTH=9;BYMONTHDAY=17
Thinking: A simple method I thought of is to parse it into JSON:
var str = "INTERVAL=8;BYMONTH=9;BYMONTHDAY=17";
var fiStr = '"' + str.replace(/=/g,'":"').replace(/;/g,'","');
var lastST = '{' + fiStr + '"}';
var Obj = JSON.parse(lastST);
console.log(Obj.BYMONTH)
Question:
How should I handle this data format?
"INTERVAL=8;BYMONTH=9;BYMONTHDAY=17".split(";")[2].split("=")[1]
What I’m more curious about is why the backend doesn’t directly return json format? It has to be processed on the front end.