A getter raises jeTypeMismatch
GetLong, GetCurrency, GetDate or another getter raises the error jeTypeMismatch
(vbObjectError + 516), although the path exists, or even though a default was given.
Environment
All versions of WKL Office JSON.
Cause
The getters convert the value found by the path and refuse values that do not fit, instead of truncating them or returning the default:
GetLongfor a number with a fraction (2.5) or outside theLongrange.GetBooleanfor a string other than"true"or"false"(compared in any case, spaces around it ignored; numbers are accepted: a number that is 0 after the conversion toDecimalis False).GetDouble,GetCurrencyorGetDecimalfor a number outside the range of the type.- A number getter for a string that is not a JSON number (
"12,5","007","+5"). GetDatefor a number (for example a Unix timestamp).- A default that does not convert to the getter's type (
GetLong(path, "abc")). - Any getter without a default for JSON
null.
The default replaces only a missing path or null. A value of the wrong type stays an error,
because silently substituting the default would hide a data problem.
Resolution
- Check the value:
Debug.Print doc.SelectSingleNode(path).ToJson. - Use the getter that matches the data:
GetDoubleorGetDecimalfor fractions,GetStringfor dates in other formats (then convert withCDateunder your own rules). - For fields that may be
null, pass a default, for exampleGetLong("$.qty", 0).
en/wiki/msaccess/json/troubleshooting/getter-type-mismatch.txt · Zadnja sprememba: uporabnika Wolfgang van der Stille