1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

x.json2: support time.Time values in encode (#16643)

* feat: json2 time.Time encode

* refactor: best var name

* fix: use 'RFC 3339' as pattern in json encode

* fix: unused var for unaliased_typ

* fix: improve test

* use the clearer test after V ad24c22, that made format_rfc3339 more stable

Co-authored-by: Delyan Angelov <delian66@gmail.com>
This commit is contained in:
Hitalo Souza
2022-12-11 11:54:28 -03:00
committed by GitHub
parent ad24c22250
commit d7c244e5ec
6 changed files with 59 additions and 2 deletions

View File

@ -107,11 +107,11 @@ fn test_bool() {
// valid conversions
assert sample_data['bool'] or { 0 }.bool() == false
assert json.Any('true').bool() == true
// invalid conversions
assert sample_data['int'] or { 0 }.bool() == true
assert sample_data['i64'] or { 0 }.bool() == true
assert sample_data['f32'] or { 0 }.bool() == true
assert sample_data['f64'] or { 0 }.bool() == true
// invalid conversions
assert sample_data['null'] or { 0 }.bool() == false
assert sample_data['arr'] or { 0 }.bool() == false
assert sample_data['obj'] or { 0 }.bool() == false