log icon indicating copy to clipboard operation
log copied to clipboard

Using another library instead of encoding/json for the JSONFormatter

Open 0xN0x opened this issue 3 months ago • 2 comments

Is your feature request related to a problem? Please describe. I was using the JSONFormatter to print structure, when i saw that encoding/json doesn't support map[interface{}]interface{}

Since the logger doesn't return any information when such an error occurs, it took me several hours of debugging to finally locate that the problem came from the json formatter (I didn't expect it not to support a data type like that).

After a bit of online digging, I discovered that this is a fairly common problem and that libraries like json-iterator (among others) try to solve it.

Describe the solution you'd like Use something other than the core library to format it to support all data types

Describe alternatives you've considered

  • Make my own logger using json-iterator
  • Create my own formatter, but the library doesn't currently seem to support custom formatter.

Additional context

json: unsupported type: map[interface {}]interface {}

0xN0x avatar May 04 '24 14:05 0xN0x

@0xN0x could this problem possibly have been improved by #123? It's in main.

op avatar May 07 '24 16:05 op

@0xN0x could this problem possibly have been improved by #123? It's in main.

I'm going to try it tonight, but since the library still uses encoding/json, I don't think the problem will be solved because it's a limitation on that side.

0xN0x avatar May 07 '24 16:05 0xN0x