-
-
Save Yardanico/6457d94ed01c5af17a5bc3810c21e5ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std/json | |
import std/algorithm | |
type | |
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