只读属性默认为false;可见属性默认为true;可用属性默认为true。该三个属性如果是默认值,不写在JSON中

This commit is contained in:
gb 2023-09-18 11:30:38 +08:00
parent d5a3f5c553
commit 9a2ff90875
2 changed files with 10 additions and 5 deletions

View File

@ -268,8 +268,11 @@ known_file_util::IJsonW* CDlgOptJson::SANEOPT::to_json(void)
jsn->set_value(L"unit", unit.c_str()); jsn->set_value(L"unit", unit.c_str());
SANEOPT::affect_str(nv, affect, false); SANEOPT::affect_str(nv, affect, false);
jsn->set_value(L"affect", nv); jsn->set_value(L"affect", nv);
if(readonly)
jsn->set_value(L"readonly", readonly); jsn->set_value(L"readonly", readonly);
if(!open)
jsn->set_value(L"visible", open); jsn->set_value(L"visible", open);
if(!enable)
jsn->set_value(L"enabled", enable); jsn->set_value(L"enabled", enable);
jsn->set_value(L"size", (int)sizeof(int)); jsn->set_value(L"size", (int)sizeof(int));
if (!auto_restore_default) if (!auto_restore_default)
@ -740,8 +743,10 @@ bool CDlgOptJson::SANEOPT::from_json(known_file_util::IJsonW* jsn)
SANEOPT::affect_str(ver, affect, true); SANEOPT::affect_str(ver, affect, true);
jsn->get_value(L"ver", ver); jsn->get_value(L"ver", ver);
jsn->get_value(L"pos", pos); jsn->get_value(L"pos", pos);
jsn->get_value(L"readonly", readonly); if (!jsn->get_value(L"readonly", readonly))
jsn->get_value(L"visible", open); readonly = false;
if (!jsn->get_value(L"visible", open))
open = true;
if (!jsn->get_value(L"enabled", enable)) if (!jsn->get_value(L"enabled", enable))
enable = true; enable = true;
if (!jsn->get_value(L"fix-id", fix_id) && !name.empty()) if (!jsn->get_value(L"fix-id", fix_id) && !name.empty())

Binary file not shown.