How to convert multiline json to single line?

I am trying to convert a multiline json to a single line json. So the existing json file I have looks like this:

When I load the file, it comes in a dictionary and not sure how to strip blank spaces in the dictionary.

 f = open('test.json') data = json.load(f) 
What I would like it to come out is the following: 19.2k 16 16 gold badges 52 52 silver badges 64 64 bronze badges asked Nov 23, 2021 at 20:51 661 3 3 gold badges 12 12 silver badges 28 28 bronze badges Did you try print(data) ? I'm pretty sure it is already how you want it. Commented Dec 9, 2021 at 20:12

1 Answer 1

Using the standard library json you can get:

import json with open('test.json') as handle: data = json.load(handle) text = json.dumps(data, separators=(',', ':')) print(text)