/ Try making a JSON value of the passed type from the passed argument. */ /
| 2022 | /* Try making a JSON value of the passed type from the passed argument. */ |
| 2023 | /*********************************************************************************/ |
| 2024 | static PJVAL MakeTypedValue(PGLOBAL g, UDF_ARGS *args, uint i, |
| 2025 | JTYP type, PJSON *top = NULL) |
| 2026 | { |
| 2027 | char *sap; |
| 2028 | PJSON jsp; |
| 2029 | PJVAL jvp = MakeValue(g, args, i, top); |
| 2030 | |
| 2031 | //if (type == TYPE_JSON) { |
| 2032 | // if (jvp->GetValType() >= TYPE_JSON) |
| 2033 | // return jvp; |
| 2034 | |
| 2035 | //} else if (jvp->GetValType() == type) |
| 2036 | // return jvp; |
| 2037 | |
| 2038 | if (jvp->GetValType() == TYPE_STRG) { |
| 2039 | sap = jvp->GetString(g); |
| 2040 | |
| 2041 | if ((jsp = ParseJson(g, sap, strlen(sap)))) { |
| 2042 | if ((type == TYPE_JSON && jsp->GetType() != TYPE_JVAL) || jsp->GetType() == type) { |
| 2043 | if (top) |
| 2044 | *top = jsp; |
| 2045 | |
| 2046 | jvp->SetValue(jsp); |
| 2047 | } // endif Type |
| 2048 | |
| 2049 | } // endif jsp |
| 2050 | |
| 2051 | } // endif Type |
| 2052 | |
| 2053 | return jvp; |
| 2054 | } // end of MakeTypedValue |
| 2055 | |
| 2056 | /* ------------------------------ The JSON UDF's ------------------------------- */ |
| 2057 |
no test coverage detected