Javascript: sparkplug-payload -> Possible to specify converion options when decoding payload?
bj00rn opened this issue · 0 comments
bj00rn commented
Hi,
Is it possible to specify conversion options for long
s etc, when decoding payload?
We coming from using protobufjs with sparkplug protocol and using toObject
by specified conversion options
:
import * as protobuf from 'protobufjs'
import protocol from './sparkplugb.proto'
const root = protobuf.parse(protocol).root
let SparkplugPayload = root.lookupType('com.cirruslink.sparkplug.protobuf.Payload')
let decodedObj = SparkplugPayload.toObject(SparkplugPayload.decode(new Uint8Array(input)), {longs: Number})
I would like to use sparkplug-payload
instead for decoding, but now my long
timestamps are no longer converted.
import { get } from 'sparkplug-payload'
let sparkplug = get("spBv1.0")
let decodedObj = sparkplug.decodePayload(new Uint8Array(input)))
Cheers!