Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/federicoceratto/nim-bencode
Bencode library for Nim
https://github.com/federicoceratto/nim-bencode
bdecode bencode nim nim-lang
Last synced: 6 days ago
JSON representation
Bencode library for Nim
- Host: GitHub
- URL: https://github.com/federicoceratto/nim-bencode
- Owner: FedericoCeratto
- License: lgpl-3.0
- Created: 2018-02-10T12:24:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-02-05T16:02:39.000Z (almost 3 years ago)
- Last Synced: 2023-03-22T12:49:29.959Z (over 1 year ago)
- Topics: bdecode, bencode, nim, nim-lang
- Language: Nim
- Size: 5.86 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
## bencode
Nim bencode library
image:https://circleci.com/gh/FedericoCeratto/nim-bencode.svg?style=svg["CircleCI", link="https://circleci.com/gh/FedericoCeratto/nim-bencode"]
image:https://img.shields.io/badge/status-alpha-orange.svg[badge]
image:https://img.shields.io/badge/version-0.1.0-orange.svg[badge]* Encode from JSON objects
* Basic unit tests
* Tested on Linux### Installation
[source,bash]
----
nimble install bencode
----### Usage
[source,nim]
----
import bencode
import tables, jsonlet decoded = bdecode("d3:bar4:spam3:fooi42ee") # returns BENode
# pretty print
pprint decoded# encode
assert bencode(33) == "i33e"
assert bencode("foo") == "3:foo"
assert bencode({"bar": "spam", "foo": "42"}.toTable) == "d3:bar4:spam3:foo2:42e"# encode from JSON
let j = %* {
"t":"aa", "y":"q", "q":"ping", "a": {
"id":"abcdefghij0123456789"
}
}
let encoded = j.bencode()----
### Contributing
Testing and PRs are welcome.