summaryrefslogtreecommitdiff
path: root/lsp-json.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-30 18:59:39 -0500
committerpommicket <pommicket@gmail.com>2022-12-30 18:59:39 -0500
commit1bd19da6910c85029c34c6d8cf65739a9e0a2127 (patch)
tree23896f33125315499f51dd1ac4a49632e2afe11f /lsp-json.c
parent72624969e99d284984614a33cabb4ed9fea31a0a (diff)
start parse rename response
Diffstat (limited to 'lsp-json.c')
-rw-r--r--lsp-json.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lsp-json.c b/lsp-json.c
index 2f6f0f1..6d6765d 100644
--- a/lsp-json.c
+++ b/lsp-json.c
@@ -465,6 +465,20 @@ JSONValue json_array_get(const JSON *json, JSONArray array, u64 i) {
return (JSONValue){0};
}
+// returns the `i`th key in `object`.
+JSONValue json_object_key(const JSON *json, JSONObject object, u64 i) {
+ if (i < object.len)
+ return json->values[object.items + i];
+ return (JSONValue){0};
+}
+
+// returns the `i`th value in `object`.
+JSONValue json_object_value(const JSON *json, JSONObject object, u64 i) {
+ if (i < object.len)
+ return json->values[object.items + object.len + i];
+ return (JSONValue){0};
+}
+
// returns NaN if `x` is not a number (ha ha).
double json_force_number(JSONValue x) {
if (x.type == JSON_NUMBER) {