0

I am converting a JSON file into HTML (which I am able to achieve) using "json2html" library . Apart from that, I am trying to add colorin one of the column depending upon the result. If it says true - I want the Background to be GREEN color , IF False, then RED color

import json2html


table = json2html.convert(json = data_to_be_sent)
report_html = table

Below is how my Output/HTML/report_html file looks like right now: All I want to do is add color to 'Success' column depending upon the result

<html>

<head>

<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,900" />

</head>

<body style="color: #333; font-family: Source Sans Pro;";>

<h2>Nightly Validation Report (2019/09/19, prod)</h2>

<h3>Nightly Validation Report (XX)</h3>

<br><br><table border="1"><tr><th>CorrelationId</th> 
<td>awsnightlyendtoend_XX_20190919T2319</td></tr><tr> 
<th>ValidationType</th><td>validate_adwactivityfact</td></tr><tr> 
<th>Success</th><td>False</td></tr><tr><th>OutputPath</th><td><ul><li><a 
href=https://XXXXX</a></li><li><a 
href=https://XXXXX</a></li></ul></td></tr><tr><th>ValidationDetail</th> 
<td>Comparison Failed: matched=211009, missing=5, mismatched=0, percent success=99.9952609779446%</td></tr></table>


</html>
Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
Ryan
  • 39
  • 1
  • 10
  • I don't know if `json2html` can add classes or styles to tags in HTML but HTML is a string so you can use ie. `.replace('False', 'False')` and then you can use CSS to set red color or `.red` – furas Sep 20 '19 at 22:01
  • it seems you have two columns - first use `` and second use `` so you can add CSS `` in string with HTML when you have `false` in JSON. – furas Sep 20 '19 at 22:06

0 Answers0