Skip to content

Am I supposed decode the payload string myself? #1782

Answered by CZEMacLeod
HubKing asked this question in Q&A
Discussion options

You must be logged in to vote

@HubKing I've done a simple example available at https://github.com/CZEMacLeod/Tasmota-Mosquitto-MQTTnet-Sample
There is an extension method ConvertPayloadToString which may do what you want, but as many payloads are utf8 encoded numbers, or often utf8 json payloads, converting them to Strings is a lot of memory usage and copying.

I've shown number parsing using Utf8Parser and Json decoding using System.Text.Json.

There are a couple of other little nice example bits in there too. Hope this helps.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by HubKing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants