package polymarket

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Polymarket_http.JsonSource

JSON parsing and body building utilities.

JSON Parsing

Sourceval parse : (Yojson.Safe.t -> 'a) -> string -> ('a, string) result

Parse a JSON response using the provided parser function.

  • returns

    Ok value on success, Error msg on parse failure

Sourceval parse_list : (Yojson.Safe.t -> 'a) -> string -> ('a list, string) result

Parse a JSON array response, applying parser to each element.

  • returns

    Ok list on success, Error msg on parse failure

JSON Body Builders

Sourceval body : Yojson.Safe.t -> string

Convert JSON to string body

Sourceval obj : (string * Yojson.Safe.t) list -> Yojson.Safe.t

Build JSON object from field list

Sourceval string : string -> Yojson.Safe.t

Wrap string as JSON string

Sourceval list : ('a -> Yojson.Safe.t) -> 'a list -> string

Map items to JSON and serialize as array

Sourceval list_single_field : string -> string list -> string

Build JSON array of single-field objects. list_single_field "token_id" ids produces [{"token_id": "id1"}, {"token_id": "id2"}, ...]