In Python, there are 2 ways to prettyprint a JSON file.
Using json module
The json module already implements some basic pretty printing in the dump and dumps functions, with the indent parameter that specifies how many spaces to indent by:
#!/us...
In Golang, there are 2 ways to pretty-print json.
Using json.MarshalIndent Function
MarshalIndent is like Marshal but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one...
Rust String Formatting and Printing Best Practices.Using println!
Prints to the standard output, with a newline. Use the format! syntax to write data to the standard output. See std::fmt for more information.
fn main() {
let name = "Bob";
pri...
In Golang, there are two ways to get the start and end date of the current month.Using time.AddDate Function
AddDate returns the time corresponding to adding the given number of years, months, and days to t. For example,
package main
import (
"fm...
Convert Slice to String in Golang.Using strings.Join Function
Converting a slice of strings to a single string is pretty easy to do in Go. The strings.Join() method is present in the standard library for this purpose, and its usage is shown below:
p...
Converting Json to string in Python.Decoding JSON
To convert string to json in Python, use the json.loads() function. The json.loads() is a built-in Python function that accepts a valid json string and returns a dictionary to access all elements. The...
A modern approach to copy text to clipboard No Flash. No frameworks. --pname-- lets you easily copy text to the clipboard. At 3kb gzipped and no need for Flash, it’s a great lightweight way to allow your visitors to copy bits of text and code on your...
Highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server.Highlight.js is a syntax highlighter written in JavaScript. It works in the browser as well as on the server. It works with pretty much any m...