Pretty print JSON dumps
I ended up using jsbeautifier: import jsbeautifier opts = jsbeautifier.default_options() opts.indent_size = 2 jsbeautifier.beautify(json.dumps(d), opts) Output: { “a”: “blah”, “c”: [1, 2, 3], “b”: “foo” }
I ended up using jsbeautifier: import jsbeautifier opts = jsbeautifier.default_options() opts.indent_size = 2 jsbeautifier.beautify(json.dumps(d), opts) Output: { “a”: “blah”, “c”: [1, 2, 3], “b”: “foo” }
Mongo includes a mongoexport utility (see docs) which can dump a collection. This utility uses the native libmongoclient and is likely the fastest method. mongoexport -d <database> -c <collection_name> Also helpful: -o: write the output to file, otherwise standard output is used (docs) –jsonArray: generates a valid json document, instead of one json object per … Read more
There is a command line option for logging. The output is saved to screenlog.n file, where n is a number of the screen. From man pages of screen: ā-Lā Tell screen to turn on automatic output logging for the windows.
Most modern browsers have a console in their developer tools, useful for this sort of debugging. console.log(myvar); Then you will get a nicely mapped out interface of the object/whatever in the console. Check out the console documentation for more details.
You could try XStream. XStream xstream = new XStream(new Sun14ReflectionProvider( new FieldDictionary(new ImmutableFieldKeySorter())), new DomDriver(“utf-8”)); System.out.println(xstream.toXML(new Outer())); prints out: <foo.ToString_-Outer> <intValue>5</intValue> <innerValue> <stringValue>foo</stringValue> </innerValue> </foo.ToString_-Outer> You could also output in JSON And be careful of circular references š
You could alternatively use jstack (Included with JDK) to take a thread dump and write the output wherever you want. Is that not available in a unix environment? jstack PID > outfile
Oracle does not supply an out-of-the-box unload utility. Keep in mind without comprehensive info about your environment (oracle version? server platform? how much data? what datatypes?) everything here is YMMV and you would want to give it a go on your system for performance and timing. My points 1-3 are just generic data movement ideas. … Read more
In Python: con = sqlite3.connect(‘database.db’) cursor = con.cursor() cursor.execute(“SELECT name FROM sqlite_master WHERE type=”table”;”) print(cursor.fetchall()) Watch out for my other answer. There is a much faster way using pandas.
Update (2021) – Java 17 now includes java.util.HexFormat (only took 25 years): HexFormat.of().parseHex(s) For older versions of Java: Here’s a solution that I think is better than any posted so far: /* s must be an even-length string. */ public static byte[] hexStringToByteArray(String s) { int len = s.length(); byte[] data = new byte[len / … Read more