Core Library

fwNgsiv2 — NGSIv2 Validation & Normalization

The NGSIv2 counterpart to fwNgsild — thinner because NGSIv2 has no JSON-LD semantic layer, but still needed for proper payload handling.

What It Does

fwNgsiv2 validates and normalizes NGSIv2 payloads, parses NGSIv2-specific query parameters, handles representation modes, and provides NGSIv2 ↔ NGSI-LD translation.

Where fwNgsild deals with the complexity of JSON-LD @context semantics, fwNgsiv2 handles the NGSIv2-specific concerns: different attribute structures, v2-specific query languages, and the translation layer needed when both protocol versions share the same storage backend.

Core Capabilities

What It Doesn't Do

No @context handling, no URI expansion/compaction, no remote context downloads. NGSIv2 uses plain attribute names — there is no JSON-LD semantic layer to deal with.

Why It Exists

The FiWorks NGSIv2 Broker needs v2-specific validation and query parsing that is fundamentally different from the NGSI-LD path. When both the NGSI-LD and NGSIv2 brokers share the same kdb storage, fwNgsiv2 provides the translation layer that maps between the two formats.

Without this library, the NGSIv2 broker would need its own inline implementation of payload validation, query parsing, and format translation — code that would inevitably diverge from the NGSI-LD side and create inconsistencies.

Dependencies

LibraryRole
fwJsonJSON parser for parsing NGSIv2 payloads into FtNode trees
fwAllocBump allocator for all memory allocation
fwHashHash tables for attribute type mappings and query caches

Note the absence of fwHttp in the dependency list — unlike fwNgsild, fwNgsiv2 never needs to download remote documents. NGSIv2 has no equivalent of @context.

fwNgsild vs fwNgsiv2

AspectfwNgsildfwNgsiv2
@context handling Full (download, cache, expand, compact) None
Payload validation NGSI-LD structure NGSIv2 structure
Query parsing NGSI-LD q syntax (URI-based) NGSIv2 q/mq syntax (dot notation)
Representation modes Simplified, concise, normalized keyValues, values, unique, normalized
Translation NGSIv2 ↔ NGSI-LD
Complexity ~3,000–5,000 lines ~1,000–2,000 lines