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

json: fix raw json string decoding crash when expected key is missing (#7206)

This commit is contained in:
Seven Du
2020-12-10 03:10:41 +08:00
committed by GitHub
parent 032ea0f4f8
commit 4a35a75b64
3 changed files with 59 additions and 2 deletions

View File

@ -111,6 +111,22 @@ pub fn tos3(s charptr) string {
}
}
// Same as `tos2`, but returns empty string on nil ptr
pub fn tos4(s byteptr) string {
if s == 0 {
return ""
}
return tos2(s)
}
// Same as `tos4`, but for char*, to avoid warnings
pub fn tos5(s charptr) string {
if s == 0 {
return ""
}
return tos3(s)
}
[deprecated]
pub fn tos_lit(s charptr) string {
eprintln('warning: `tos_lit` has been deprecated, use `_SLIT` instead')