From ae54c8891885176b7d4a66c9015556b290dae36d Mon Sep 17 00:00:00 2001 From: "Sean T. Allen" Date: Wed, 22 Jan 2025 17:12:36 +0000 Subject: [PATCH] Remove JsonExtractor from the requests package The JsonExtractor is now part of the ponylang/json library. --- .release-notes/38.md | 5 ++ corral.json | 2 +- github_rest_api/request/json.pony | 81 ------------------------------- 3 files changed, 6 insertions(+), 82 deletions(-) create mode 100644 .release-notes/38.md diff --git a/.release-notes/38.md b/.release-notes/38.md new file mode 100644 index 0000000..f1b0030 --- /dev/null +++ b/.release-notes/38.md @@ -0,0 +1,5 @@ +## Remove `JsonExtractor` from the requests package #38 + +Previously, the `request` package included a `JsonExtractor` class that was used to extract JSON data from a response. This class has been removed from the package. If you were using this class, you will need to update your code to use the `JsonExtractor` from the [`ponylang/json`](https://github.com/ponylang/json) library instead instead. + +`JsonExtractor` is available in all versions of `ponylang/json` starting with 0.2.0. diff --git a/corral.json b/corral.json index be8738a..ac06073 100644 --- a/corral.json +++ b/corral.json @@ -16,7 +16,7 @@ }, { "locator": "github.com/ponylang/json.git", - "version": "0.1.0" + "version": "0.2.0" } ], "info": { diff --git a/github_rest_api/request/json.pony b/github_rest_api/request/json.pony index 3aeb9d6..7896bb5 100644 --- a/github_rest_api/request/json.pony +++ b/github_rest_api/request/json.pony @@ -4,84 +4,3 @@ use "net" interface val JsonConverter[A: Any #share] fun apply(json: JsonType val, creds: Credentials): A ? - -class val JsonExtractor - let _json: JsonType val - - new val create(json: JsonType val) => - _json = json - - fun val apply(idx_or_key: (String | USize)): JsonExtractor val ? => - match (_json, idx_or_key) - | (let a: JsonArray val, let idx: USize) => - JsonExtractor((a.data)(idx)?) - | (let o: JsonObject val, let key: String) => - JsonExtractor((o.data)(key)?) - else - error - end - - fun val size(): USize ? => - match _json - | let a: JsonArray val => - a.data.size() - | let o: JsonObject val => - o.data.size() - else - error - end - - fun val values(): Iterator[JsonType val] ? => - match _json - | let a: JsonArray val => - a.data.values() - else - error - end - - fun val pairs(): Iterator[(String, JsonType val)] ? => - match _json - | let o: JsonObject val => - o.data.pairs() - else - error - end - - fun val as_array(): Array[JsonType] val ? => - match _json - | let a: JsonArray val => - a.data - else - error - end - - fun val as_object(): Map[String, JsonType] val ? => - match _json - | let o: JsonObject val => - o.data - else - error - end - - fun val as_string(): String ? => - _json as String - - fun val as_none(): None ? => - _json as None - - fun val as_f64(): F64 ? => - _json as F64 - - fun val as_i64(): I64 ? => - _json as I64 - - fun val as_bool(): Bool ? => - _json as Bool - - fun val as_string_or_none(): (String | None) ? => - match _json - | let s: String => s - | let n: None => n - else - error - end