X-Git-Url: https://gerrit.onap.org/r/gitweb?p=ccsdk%2Fdistribution.git;a=blobdiff_plain;f=dgbuilder%2Ftools%2Fjson_to_html_table;fp=dgbuilder%2Ftools%2Fjson_to_html_table;h=20c9cfeb6428fbcceb8999621174a07b1bc1f32a;hp=0000000000000000000000000000000000000000;hb=d1569975bb18f4359fac18aa98f55b69c248a3ad;hpb=a016ea661ff5767a3539734c4c07ef974a6e4614 diff --git a/dgbuilder/tools/json_to_html_table b/dgbuilder/tools/json_to_html_table new file mode 100755 index 00000000..20c9cfeb --- /dev/null +++ b/dgbuilder/tools/json_to_html_table @@ -0,0 +1,144 @@ +try{ +var jsonStr='{}'; +jsonObj=JSON.parse(jsonStr); +var htmlObj ={}; +var objectId =0; +var level=0; +var htmlStr="" +htmlStr += ""; +htmlStr += ""; +htmlStr += ""; +htmlStr += ""; +htmlStr += ""; +htmlStr += "
\n\n"; +console.log("
"); +printObjectValues(jsonObj,null,level); +console.log("
"); +htmlStr += "\n\n
"; +//var pattern = new RegExp("\\n","g"); +//htmlstr =htmlStr.replace(pattern,''); +htmlStr += ""; +//console.log(htmlStr); + +//console.dir(htmlObj); +var keyObj={}; +for (var key in htmlObj) { + var idx = key.lastIndexOf("."); + if(idx != -1){ + var str = key.substr(0,idx); + keyObj[str] =''; + }else{ + keyObj[key] =''; + } + //console.log(str); +} + +console.dir(keyObj); +console.log(""); + +function tabs(level){ +return ''; +} +function tabsOrig(level){ + var tabs=""; + for(var i=0;i" + pkey + "." + key + "" +printValue(v) + "" ); + htmlObj[pkey + "." + key ] = printValue(v); + }else{ + //console.log( key + ":" +printValue(v) ); + console.log("" + key + "" +printValue(v) + "" ); + htmlObj[key ] = printValue(v); + } + //printValue(v); + } + } +} +}catch(err){ + console.log(err); +} +return output; +} + +}catch(err){ +console.log( err ); +} + +function printArrayValues(arrObj,pkey,level){ +var output =""; +var arrayHtmlStr =""; +try{ + for(var i=0;arrObj != null && i" + pkey + "." + key + "" +printValue(o) + "" ); + htmlObj[pkey + "." + key ] = printValue(o); + //console.log(pkey + ":" +printValue(o) ); + //output += tabs(level) + "" + printValue(o) + "\n"; + } + } +}catch(err){ + console.log(err); +} +return output; +} + +function printValue(obj){ + if(obj != undefined){ + if(typeof obj == 'string'){ + return "'" + obj + "'"; + }else{ + return obj; + } + }else{ + return ""; + } +}