From 1331e51dae52bc560122d2169a6f047f297f2f5e Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Mon, 14 Jul 2025 16:45:15 +0800 Subject: [PATCH] FIX: The value maybe string or int JIRA: [STUDIO-13018] Change-Id: I4af161431fb51e1e0234bc37de8346b45f3ca4b7 (cherry picked from commit 4e2934685033c352ea2c3baded585381c285a90d) --- src/slic3r/GUI/DeviceManager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 7a6629c456..f4df504896 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2989,7 +2989,18 @@ int MachineObject::parse_json(std::string payload, bool key_field_only) } } if (j_pre["print"].contains("plate_idx")){ // && m_plate_index == -1 - m_plate_index = j_pre["print"]["plate_idx"].get(); + if (j_pre["print"]["plate_idx"].is_number()) + { + m_plate_index = j_pre["print"]["plate_idx"].get(); + } + else if (j_pre["print"]["plate_idx"].is_string()) + { + try + { + m_plate_index = std::stoi(j_pre["print"]["plate_idx"].get()); + } + catch (...) { BOOST_LOG_TRIVIAL(error) << "parse_json: failed to convert plate_idx to int"; } + } } } if (j_pre.contains("system")) {