Python Highlight specific text in json document on terminal
<p>I am interested in highlighting a specific portion of the json document based on some arbitrary matching algorithm. For example</p>

<pre><code>{
  "text" : "hello world"
}
</code></pre>

<p>I searched for "hello" and above json document has hello in it. How to highlight that particular portion "hello" while displaying the document on the terminal using python? Also, the json has to be pretty printed.</p>

<p>Expected</p>

<pre><code>{
  "text" :  " `hello` world"
}
</code></pre>

<p>Text that is qoutes should be displayed in red color.</p>

<p>I can't comment :(</p>

<p>The answer here might be able to help you: <a href="http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python">Print in terminal with colors using Python?</a></p>

<p>For example, you could use termcolor (if you are using a linux style terminal) and replace "hello" with colored("hello", "red")</p>

<pre><code>from termcolor import colored

sample_text = "colored hello there !"
print(sample_text)

print(sample_text.replace("hello", colored("hello", "red")))
</code></pre>

python json pprint