12 ms·
The point is that it's layered. 1. Validate your Buffer/UInt8Array for valid size/encoding/etc first 2. Parse it to an object via JSON.parse or whatever your
by 90s_dev 1y ago
The point is that it's layered.
1. Validate your Buffer/UInt8Array for valid size/encoding/etc first
2. Parse it to an object via JSON.parse or whatever your use-case needs
3. Reach into it with this function to get data if it matches the type you need
This code only deals with #3 and makes a few assumptions about #2 (e.g. no undefined, typical JSON-like object, etc).