How to read an optional value?
Closed this issue · 3 comments
mcordova1967 commented
I have this fragment, could you please provide a sample code to read the "validator" field, which may or may not be present.
{
"uri": "/ms/categ/delete",
"sql": "execute sp_categ_delete ${categ_id}",
"function": "dbexec",
"fields": [
{"name": "categ_id", "type": "integer", "required": "true"}
],
"validator": { "function": "dbexist", "sql": "sp_categ_inuse ${categ_id}" }
}
Thank you very much!
Martin
eteran commented
This should do it:
json::value obj = json::parse(file);
if (has_key(obj, "validator")) {
auto validator = obj["validator"];
// use validator
}
mcordova1967 commented
Thank you!
…On Thu, Mar 10, 2022 at 11:22 AM Evan Teran ***@***.***> wrote:
This should do it:
json::value obj = json::parse(file);
if has_key(obj , "validator")) {
auto validator = obj["validator"];
// use validator
}
—
Reply to this email directly, view it on GitHub
<#13 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AW34RACRDKGQHJJG2FPFY3LU7IHTZANCNFSM5QJWWUGQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
* Framework Dinámica
Plataforma avanzada para desarrollo rápido de aplicaciones Web/SQL con Java
EE y Eclipse
http://www.martincordova.com
* El BLOG de Dinámica:
http://dinamicaframework.blogspot.com/
* El Canal de Dinámica en Youtube:
http://www.youtube.com/dinamicaframework
* Facebook
https://www.facebook.com/FrameworkDinamica
Martín Córdova y Asociados, C.A.
J-31134803-4 / Caracas, Venezuela
Cel: 58-424-2686639
eteran commented
It's not heavily advertised, but the WIKI also has more information on the API:
https://github.com/eteran/cpp-json/wiki/API
Relevant section here: https://github.com/eteran/cpp-json/wiki/API#object-inspection