-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,25 @@ | ||
# BinaryToJSON | ||
format binary data to JSON. | ||
A Deno module helper class that convert binary array buffer to JSON format. | ||
Binary interpretation is defined by JSON. | ||
|
||
This module depends on https://deno.land/x/binary_reader@v0.1.6/mod.ts . | ||
|
||
## Usage | ||
```typescript | ||
import { BinaryToJSON } from "./binary_to_json.ts"; | ||
|
||
const buffer = new ArrayBuffer(4); | ||
const arry = new Uint8Array(buffer); | ||
arry[0] = 0x0A; | ||
arry[1] = 0x0B; | ||
arry[2] = 0x0C; | ||
arry[3] = 0x0D; | ||
const format = [{"dat": 4}]; | ||
const b2j = new BinaryToJSON(); | ||
const data: any = b2j.convert(arry, format); // default endian is big | ||
|
||
// => {"dat": 168496141 } # 0x0A0B0C0D | ||
``` | ||
|
||
|
||
more info: please refer to test.ts. |