nodejs object_to_json

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-09-27 01:00:00 +00:00
parent b3401b61ed
commit 89593b97c2
3 changed files with 93 additions and 24 deletions

View File

@@ -21059,24 +21059,7 @@ Examples:
** link:rootfs_overlay/lkmc/nodejs/read_stdin_to_string.js[] Question: https://stackoverflow.com/questions/30441025/read-all-text-from-stdin-to-a-string
* `class`
** link:rootfs_overlay/lkmc/nodejs/object_to_string.js[]: `util.inspect.custom` and `toString` override experiment: https://stackoverflow.com/questions/24902061/is-there-an-repr-equivalent-for-javascript/26698403#26698403
+
Output:
+
....
util.inspect
my type is MyClassUtilInspectCustom and a is 1 and b is 2
console.log
my type is MyClassUtilInspectCustom and a is 1 and b is 2
toString
[object Object]
util.inspect
MyClassToString { a: 1, b: 2 }
console.log
MyClassToString { a: 1, b: 2 }
toString
my type is MyClassToString and a is 1 and b is 2
....
** link:rootfs_overlay/lkmc/nodejs/object_to_json.js[]: `toJSON` examples
* link:rootfs_overlay/lkmc/nodejs/http.js[]: `http` module to create a simple HTTP server: https://nodejs.org/api/http.html
===== NPM