| 184 | } |
| 185 | |
| 186 | void ckpt_json_object_key(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
| 187 | { |
| 188 | const ScriptArgs args(Parser, Param, NumArgs, "json_object_key"); |
| 189 | nlohmann::json* get = tree(args, 0); |
| 190 | const int index = args.num(1); |
| 191 | if (!get->is_object() || index < 0 || index >= (int)get->size()) { |
| 192 | args.fail("argument 2 is index %d, out of range", index); |
| 193 | } |
| 194 | auto it = get->cbegin(); |
| 195 | std::advance(it, index); |
| 196 | ReturnValue->Val->Pointer = strToRet(it.key()); |
| 197 | } |