Answer the question
In order to leave comments, you need to log in
How to correctly generate JSON code to display the result of a loop?
Hello! Who can tell me how to correctly form the JS code of the FOR cycle so that the output is just such a text in its pure form.
[{
"text": "{{status 1}}",
"callback_data": "{{tid 1}}"
}] ,
[{
"text": "{{status 2}}",
"callback_data": " {{tid 2}}"
}],
Code itself:
var code = [];
for (var i = 1; i < 3; i++){
code[i] =
[{
"text": "{{status [i]}}",
"callback_data": "{{tid [i]}}"
}],
}
var myJSON = JSON.stringify(code);
resolve(myJSON);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question