Skip to content

Instantly share code, notes, and snippets.

@markodayan
Last active August 21, 2022 01:47
Show Gist options
  • Save markodayan/1def62511f1e980a8c01fe0629036ecd to your computer and use it in GitHub Desktop.
Save markodayan/1def62511f1e980a8c01fe0629036ecd to your computer and use it in GitHub Desktop.
JSON to Byte Array (Chris Redfield object)
// We have a string -> "{"name":"Chris Redfield","age":30,"job":"STARS soldier"}"
// The string represented as an array of bytes
// with decimal values where each byte ranges from 0 - 255
[
123, 34, 110, 97, 109, 101, 34, 58, 34, 67,
104, 114, 105, 115, 32, 82, 101, 100, 102, 105,
101, 108, 100, 34, 44, 34, 97, 103, 101, 34,
58, 51, 48, 44, 34, 106, 111, 98, 34, 58,
34, 83, 84, 65, 82, 83, 32, 115, 111, 108,
100, 105, 101, 114, 34, 125
]
// The string represented as an array of bytes
// with hexadecmial values where each byte ranges from 00 - FF
[
'7B', '22', '6E', '61', '6D',
'65', '22', '3A', '22', '43',
'68', '72', '69', '73', '20',
'52', '65', '64', '66', '69',
'65', '6C', '64', '22', '2C',
'22', '61', '67', '65', '22',
'3A', '33', '30', '2C', '22',
'6A', '6F', '62', '22', '3A',
'22', '53', '54', '41', '52',
'53', '20', '73', '6F', '6C',
'64', '69', '65', '72', '22',
'7D'
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment