Skip to content

Instantly share code, notes, and snippets.


Yardanico/tt.nim Secret

Created Aug 1, 2020
What would you like to do?
import std/json
import std/algorithm
EncodedHeaders* = tuple[signed: string; canonical: string]
KeyValue = tuple[key: string; val: string]
proc encodedQuery(input: openArray[KeyValue]): string =
## encoded a series of key/value pairs as a query string
echo input
let query = input.sortedByIt((it.key, it.val))
echo query
proc encodedQuery(node: JsonNode): string =
var query: seq[KeyValue]
for q in node.pairs:
query.add (key: "hello", val: $q.val)
echo repr query
result = encodedQuery(query)
var cq = newJObject()
cq["a"] = newJInt(1)
cq["b"] = newJInt(2)
let enc = cq.encodedQuery()
echo enc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment