binary-parser icon indicating copy to clipboard operation
binary-parser copied to clipboard

Array of strings?

Open jdbool opened this issue 6 years ago • 2 comments

Looks like this is the only way, which is really messy.

.array('strings', {
	type: new Parser()
		.string('text', {
			length: 64,
			stripNull: true
		}),
	length: 'stringCount'
})

That would result in something like this:

"strings": [
	{ "text": "hello" },
	...
]

Something more ideal would just be an actual array of strings:

"strings": [ "Hello", ... ]

jdbool avatar Mar 30 '19 21:03 jdbool

.array('strings', {
	type: new Parser()
		.string('text', {
			length: 64,
			stripNull: true
		}),
	length: 'stringCount',
	formatter: arr => arr.map(item => item.text)
})

The only way I see tbh (but it works!)

p0358 avatar Dec 12 '19 10:12 p0358

Just made this "workaround" for the array of strings, but an options to actually make a proper array of strings would be very welcome!

Rechdan avatar Oct 18 '20 05:10 Rechdan