Explorer

definy.json-string-field

description
The first string value of "key" in the JSON text ("" if not found). It accepts both "key":"value" and "key": "value" (pretty-printed JSON such as the Cloudflare API). It does not handle escapes
type
Fn(json: String, key: String) -> String
expression
fn(json$0, key$1) =>
  let compact$2 = @definy.json-string-after(
      json: $0,
      pattern: @core.string-concat(left: @core.string-concat(left: "\"", right: $1), right: "\":\"")
    );
  match @core.equal(left: $2, right: "") {
    true =>
      @definy.json-string-after(
        json: $0,
        pattern: @core.string-concat(left: @core.string-concat(left: "\"", right: $1), right: "\": \"")
      ),
    false =>
      $2
  }
visibility
public
definy.json-string-field (project definy, branch main, snapshot l0VFjJZP174d8CbZWFoujAGTYjgsQu4uTq5uWCZaXgo)
id: ty9ISSXAjn3Yi0yF0PB2haJuDR5bQiFbtwM23qBwQkc
content hash: HJoTtudmsYqj6RZ5Ylw6Xsf8C7Ol5wP0sjuZ5-NHhJs