Home > Back-end >  Json object conversion
Json object conversion

Time:10-01


/* this code is used to js script,
Baidu character recognition, not directly use,
Now, with JSON. Stringify in groups for the object,
Then use the following code conversion words,
The question now translate, H, 4,,
What I want is, h4
How to cancel the comma, or a better way of thinking,
*/
Var data=https://bbs.csdn.net/topics/[{
"Words", "H"
}, {
"Words" : "4"
}, {
"Words" : "points"
}];
Var len=eval (data). The length;

Var arr=[];
for(var i=0; IArr [I]=[];
Arr [I] [0]=data [I] words;
Arr [I] [1]=data [I] the age;
Input (arr) [I]//input text,
}


CodePudding user response:

You have got the result array, it is ok to join together as the string

 var data=https://bbs.csdn.net/topics/[{
"Words", "H"
}, {
"Words" : "4"
}, {
"Words" : "points"
}];
Var arr=[];
Data. The forEach (e=& gt; {
Arr. Push (e.w ords)
})
The console. The log (arr. Join (" "))//call the join connection arr elements, it is ok to

CodePudding user response:

Thank you very much, because I learned thoroughly, will only patchwork,
  • Related