| 1206 | |
| 1207 | template<> |
| 1208 | void global_from_json(context & ctx, const nlohmann::ordered_json & json_obj, bool mark_input) { |
| 1209 | // printf("global_from_json: %s\n" , json_obj.dump(2).c_str()); |
| 1210 | if (json_obj.is_null() || !json_obj.is_object()) { |
| 1211 | throw std::runtime_error("global_from_json: input JSON value must be an object"); |
| 1212 | } |
| 1213 | for (auto it = json_obj.begin(); it != json_obj.end(); ++it) { |
| 1214 | JJ_DEBUG("global_from_json: setting key '%s'", it.key().c_str()); |
| 1215 | ctx.set_val(it.key(), from_json(it.value(), mark_input)); |
| 1216 | } |
| 1217 | } |
| 1218 | |
| 1219 | // recursively convert value to JSON string |
| 1220 | // TODO: avoid circular references |