@@ -83,9 +83,10 @@ Symbols::ValuePtr convertJsonNumberToValue(const nlohmann::json& json) {
8383 * @brief Recursively converts a JSON object to VoidScript ObjectMap
8484 *
8585 * @param json The JSON object to convert
86+ * @param context Additional context information
8687 * @return Symbols::ObjectMap The converted ObjectMap
8788 */
88- Symbols::ObjectMap convertJsonObjectToMap (const nlohmann::json& json) {
89+ Symbols::ObjectMap convertJsonObjectToMap (const nlohmann::json& json, const std::string& context = " " ) {
8990 Symbols::ObjectMap result;
9091
9192 for (auto it = json.begin (); it != json.end (); ++it) {
@@ -124,14 +125,14 @@ Symbols::ObjectMap convertJsonObjectToMap(const nlohmann::json& json) {
124125 } else if (element.is_string ()) {
125126 arrayMap[indexKey] = Symbols::ValuePtr (element.get <std::string>());
126127 } else if (element.is_object ()) {
127- arrayMap[indexKey] = Symbols::ValuePtr ( convertJsonObjectToMap ( element) );
128+ arrayMap[indexKey] = jsonToValueWithContext ( element, context );
128129 } else if (element.is_array ()) {
129- arrayMap[indexKey] = Symbols::ValuePtr ( convertJsonObjectToMap ( element) );
130+ arrayMap[indexKey] = jsonToValueWithContext ( element, context );
130131 }
131132 }
132133 result[key] = Symbols::ValuePtr (arrayMap);
133134 } else if (value.is_object ()) {
134- result[key] = Symbols::ValuePtr ( convertJsonObjectToMap ( value) );
135+ result[key] = jsonToValueWithContext ( value, context );
135136 }
136137 }
137138
@@ -282,14 +283,14 @@ Symbols::ValuePtr jsonToValueWithContext(const nlohmann::json& json, const std::
282283 } else if (element.is_string ()) {
283284 arrayMap[indexKey] = Symbols::ValuePtr (element.get <std::string>());
284285 } else if (element.is_object ()) {
285- arrayMap[indexKey] = Symbols::ValuePtr ( convertJsonObjectToMap ( element) );
286+ arrayMap[indexKey] = jsonToValueWithContext ( element, context );
286287 } else if (element.is_array ()) {
287- arrayMap[indexKey] = Symbols::ValuePtr ( convertJsonObjectToMap ( element) );
288+ arrayMap[indexKey] = jsonToValueWithContext ( element, context );
288289 }
289290 }
290291 return Symbols::ValuePtr (arrayMap);
291292 } else if (json.is_object ()) {
292- return Symbols::ValuePtr (convertJsonObjectToMap (json));
293+ return Symbols::ValuePtr (convertJsonObjectToMap (json, context ));
293294 } else {
294295 throw std::runtime_error (createJsonErrorMessage (" JSON to ValuePtr conversion" ,
295296 " unknown" , context));
0 commit comments