viant / toolbox

Toolbox - go utility library
Apache License 2.0
197 stars 29 forks source link

IsCompleteJSON returns false for strings #19

Closed pallavJha closed 5 years ago

pallavJha commented 5 years ago

The function, IsCompleteJSON, returns false when the input is "abc". However, Go's json.Valid() returns true for the same.

https://github.com/viant/toolbox/blob/5994d07d8d5cd079b2ac2ca2d0ca14f9ab6a268f/json.go#L13

adranwit commented 5 years ago

The original intention of that function was to check if a text is complete JSON structure (map or array), as opposed to a primitive JSON value I guess the devil is in the details,

Would renaming IsCompleteJSON to IsStructuredJSON address your concern?

pallavJha commented 5 years ago

Yes, it would do. Now, the caller of the function must know the difference between structured and primitive JSON.

adranwit commented 5 years ago

addressed in https://github.com/viant/toolbox/releases/tag/v0.24.0