Read the timestamp and version
In the native quickstart, the decoder returns tag-keyed JSON. Read tag 2 as an unsigned 64-bit integer and tag 65 as the packet version. The supplied packet has values 9007199254740993 and 19. Fields are sparse: check for presence before using a value.

Append --fields to the run command from the quickstart. For example, on Linux run ./lib/read example.klv --fields with the C executable. The final line reads 9007199254740993 19.
- C
- C++
- C#
- Go
- Python
#include <inttypes.h>
#include <stdio.h>
#include "misb0601_typed.h"
static void read_fields(uint8_t *packet, size_t size) {
misb0601_tag_value_result tags = {0};
int rc = Misb0601DecodeTagValues(packet, size, MISB0601_SORT_BY_TAG, &tags);
if (rc == MISB0601_STATUS_OK || rc == MISB0601_STATUS_PARTIAL) {
misb0601_local_set fields;
if (misb0601_local_set_from_tag_values(&tags, &fields)) {
uint64_t timestamp;
uint8_t version;
if (misb0601_local_set_try_get_uint64(&fields, MISB0601_FIELD_PRECISION_TIMESTAMP, ×tamp) &&
misb0601_local_set_try_get_uint8(&fields, MISB0601_FIELD_VERSION, &version))
printf("%" PRIu64 " %u\n", timestamp, (unsigned)version);
misb0601_local_set_free(&fields);
}
}
Misb0601TagValueResultFree(&tags);
}
#include "misb0601_typed.hpp"
#include <iostream>
#include <vector>
static void read_fields(misb0601::Library &lib, const std::vector<uint8_t> &packet) {
misb0601::LocalSet fields(lib.DecodeTagValues(packet.data(), packet.size()));
auto timestamp = fields.UInt64(MISB0601_FIELD_PRECISION_TIMESTAMP);
auto version = fields.UInt8(MISB0601_FIELD_VERSION);
if (timestamp && version)
std::cout << *timestamp << ' ' << unsigned(*version) << '\n';
}
using LibMisb.Misb0601;
static class Fields
{
internal static void Read(Misb0601Decoder decoder, byte[] packet)
{
var fields = decoder.DecodeLocalSet(packet);
if (fields.TryGetUInt64(Misb0601Field.PrecisionTimestamp, out var timestamp) &&
fields.TryGetUInt8(Misb0601Field.Version, out var version))
Console.WriteLine($"{timestamp} {version}");
}
}
package main
import (
"fmt"
sdk "github.com/impleotv/libmisb-sdk-go/misb0601abi"
)
func readFields(decoder *sdk.Decoder, packet []byte) {
fields, err := decoder.DecodeLocalSet(packet)
must(err)
timestamp, hasTime := fields.UInt64(2)
version, hasVersion := fields.UInt8(65)
if hasTime && hasVersion {
fmt.Println(timestamp, version)
}
}
def read_fields(decoder, packet):
fields = decoder.decode_local_set(packet)
timestamp = fields.try_get_uint64(2)
version = fields.try_get_uint8(65)
if timestamp is not None and version is not None:
print(timestamp, version)
Browser and Node.js
When you already have the packet bytes and an open web decoder from the web quickstart, read the version from the parsed object. Store the string containing the timestamp before crossing a JavaScript Number boundary:
const exact = decoder.requestJSON(packet);
const {status, value} = JSON.parse(exact);
if (status === 'ok') {
console.log(value.Version); // 19
console.log(exact); // contains the full integer 9007199254740993
}
Next, encode a packet and inspect its validation report with the native SDK. For JavaScript, keep the exact JSON envelope when exchanging the timestamp. See revisions, JSON, and partial results.