Chapter 8. Using JSON for Binary Data Transfer

In this chapter, we will discuss the intersection between JSON and binary data. Here, you'll find the following recipes:

  • Encoding binary data as a base64 string using Node.js
  • Decoding binary data from a base64 string using Node.js
  • Encoding and decoding binary data as a base64 string using JavaScript in the browser
  • Encoding data as BSON using Json.NET
  • Decoding data from BSON using Json.NET
  • Using DataView to access ArrayBuffer
  • Encoding and decoding base64 using an ArrayBuffer
  • Compressing object-body content from a Node.js server built using the express module

Introduction

There are typically two reasons why you might want to think about binary representation when using JSON: either because you need to carry binary ...

Get JavaScript JSON Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.