Добавил еще ведущие нули к миллисекундам, если кому-то еще когда-то этот код понадобится
log = function (text, color, define){ var id, time, thread, logHtml, textLog; define = (typeof define == 'string') ? define.split(/[\s,.|:;]+/g) : define; if(typeof define === 'object' && define !== null){ if(Array.isArray(define)){ id = define.indexOf('id') > -1; time = define.indexOf('time') > -1; thread = define.indexOf('thread') > -1; } else{ id = define.id == true; time = define.time == true; thread = define.thread == true; } } else id = time = thread = true; id = id ? '<a href="action://action' + ScriptWorker.GetCurrentAction() + '" style="color:gray;">[' + ScriptWorker.GetCurrentAction() + ']</a>' : ''; time = time ? ' ' + getTime() : ''; thread = thread ? ' Поток №' + thread_number() : ''; logHtml = (id || time || thread) ? id + '<span style="color: white">' + time + thread + ' : </span>' : ''; logHtml += '<span style="color:' + (color ? color : 'white') + '">' + text + '</span>'; textLog = '[' + ScriptWorker.GetCurrentAction() + ']' + time + thread + ' : ' + text function getTime(){ var checkTime = function(i){ return (i < 10) ? "0" + i : i; }; var checkMilliSeconds = function(ms){ if (ms < 10) { return "00" + ms; } else if (ms < 100) { return "0" + ms; } else { return ms; } }; var d = new Date(); var hh = checkTime(d.getHours()); var mm = checkTime(d.getMinutes()); var ss = checkTime(d.getSeconds()); var ms = checkMilliSeconds(d.getMilliseconds()); return '[' + hh + ':' + mm + ':' + ss + '.' + ms + ']'; }; Logger.WriteHtml(logHtml, textLog); }Как значения json превратить в список?
-
Прошу помощи. Помогите разобраться, пожалуйста.
Вытащил из json отдельные значения:
[102292856,145117876,126947243,151610706,144299547,113039122,139667243,22936370,160062783,156095666,151598450,151610616,150133724,152752672,114825276,155140946,142959429,161079094,97780966,18243427,19600439,155147040,147980823,153928214,145132155,160279127,115430781,161388084,160237733,152146213,16586974,147850062,160371093,141772122,161143814,141770803,41658634,119850987,161029509,157776222,159022713,151231838,143587296,158100993,139187951,141118768,137753339,143620537,143587307,8724620,146265646,44552248,143000376,143587321,144436349,143473405,143856089,158986777,142620040,144992606,113999487,59161275,114521545,152610136,75310020,51175566,145254046,159003846,62031212,148980343,17186122,147596685,64328842,45996302,26384815,156469198,51941046,160630622,161592549,147759579,45844169,17400676,160577792,114577897,161978889,159246157,159669476,146573841,159693865,146930952,108753882,162468459,142459212,163053314,86667976,161592550,160124847,140165566,144484496,158797249]
Как мне превратить его в список чтобы использовать в цикле? -
Поменял json на строку. Обрубил прямые кавычки в начале и в конце через [[FORMATTED_JSON_STRING]].slice(1,-1) и распарсил в список. Но как-то кастыльно получилось. Есть элегантный способ?
-
@zzsnowballzz главное работает!
-
@zzsnowballzz said in Как значения json превратить в список?:
Поменял json на строку. Обрубил прямые кавычки в начале и в конце через [[FORMATTED_JSON_STRING]].slice(1,-1) и распарсил в список. Но как-то кастыльно получилось. Есть элегантный способ?
Это и есть список, просто поменяйте формат через действие "Изменить формат" из модуля "Json"
