You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add new primitive types for location and generic JSON #444
Question on this requirement: Does it bring in support for JSON encoding with Sparkplug ? Is this all kinds of JSON such as plain JSON, zipped JSON, BSON etc ?
Picking this up for M2. Nothing is implemented — there is no Document type and no location type in the specification — but there is already a recorded decision, and two things have changed since it was made.
The existing decision
docs/sparkplug_4.0.0_features/ records this issue as Partially included, with the note:
Agree on lat/long/altitude/timestamp — get clarification on JSON part — Add 'Document' data type for JSON data
So the location half is agreed and the JSON half is blocked pending clarification.
First recommendation: split the issue
Location and generic JSON are unrelated features that happen to have arrived in the same bullet of #432. Keeping them together means the half that has a decision is blocked by the half that does not. I would split this into two issues and let the location work proceed.
The JSON half
MetaData.content_type already exists and the specification already uses it for exactly this purpose: multi-part file publishing requires content_type to be set to application/octet-stream. A JSON-valued metric can therefore be a String or Bytes metric carrying content_type = "application/json", with no new DataType at all.
That may be the entire answer to "get clarification on JSON part", and it is worth settling before adding Document. A new DataType is justified only if it buys something content_type does not — for instance an obligation on consumers to parse and validate, which a media type hint does not impose.
@ravisubramanyan's question above was never answered, and half of it is now moot. It asked whether this brings JSON encoding support, and whether that covers plain JSON, zipped JSON, BSON and so on. Those are two different things:
Sparkplug 4 now has a JSON encoding of the whole payload, spJv4.0, defined in JSON encoding for sparkplug #231. That is a wire format, and it is done.
A JSON-valued metric is a separate question, and is what this issue is about. Compression is also already handled separately, by the payload-level compressed arm, so a "zipped JSON" metric is not a distinct type either.
One new design question the JSON encoding creates. In spJv4.0, a JSON-valued metric is either an escaped string or inline JSON. Inline reads better but puts a value with no fixed schema inside a schema-validated payload, and the JSON Schema would have to admit it. This needs deciding if Document goes ahead; it did not exist as a question when the original decision was recorded.
The location half
The agreed set — latitude, longitude, altitude, timestamp — is four values, so it is a composite rather than a primitive. v4 already has Template and PropertySet for composites, and adding a primitive type per domain concept does not scale: the same argument would bring quaternions, colours and units of measure.
The trade is interoperability. A primitive is understood by every implementation without agreement; a well-known Template definition has to be agreed and then recognised by name, which is weaker, but it costs no enum value and no schema change, and it extends to the next domain concept without another round.
Worth noting that DataType values were just renumbered in #660 to close the gap left by removing Text, so anything added now lands at 35 and above, after Command.
Suggested questions for the working group
Split location and generic JSON into separate issues?
For JSON: is content_type = "application/json" on a String or Bytes metric sufficient, or does a Document type buy something it does not?
If Document goes ahead: escaped string or inline JSON in spJv4.0, and what does the JSON Schema say about it?
For location: a new primitive, or a well-known Template definition?
Related: #575 is the TCK tracker for the DataSet work, not this one; #580 is the TCK tracker for this issue, and like all TCK work it is blocked until #641 lands.
Activity
ravisubramanyan commentedon Sep 19, 2023
Question on this requirement: Does it bring in support for JSON encoding with Sparkplug ? Is this all kinds of JSON such as plain JSON, zipped JSON, BSON etc ?
[#495] Remove the Text DataType
wes-johnson commentedon Nov 25, 2026
Picking this up for M2. Nothing is implemented — there is no
Documenttype and no location type in the specification — but there is already a recorded decision, and two things have changed since it was made.The existing decision
docs/sparkplug_4.0.0_features/records this issue as Partially included, with the note:So the location half is agreed and the JSON half is blocked pending clarification.
First recommendation: split the issue
Location and generic JSON are unrelated features that happen to have arrived in the same bullet of #432. Keeping them together means the half that has a decision is blocked by the half that does not. I would split this into two issues and let the location work proceed.
The JSON half
MetaData.content_typealready exists and the specification already uses it for exactly this purpose: multi-part file publishing requirescontent_typeto be set toapplication/octet-stream. A JSON-valued metric can therefore be aStringorBytesmetric carryingcontent_type = "application/json", with no new DataType at all.That may be the entire answer to "get clarification on JSON part", and it is worth settling before adding
Document. A new DataType is justified only if it buys somethingcontent_typedoes not — for instance an obligation on consumers to parse and validate, which a media type hint does not impose.@ravisubramanyan's question above was never answered, and half of it is now moot. It asked whether this brings JSON encoding support, and whether that covers plain JSON, zipped JSON, BSON and so on. Those are two different things:
spJv4.0, defined in JSON encoding for sparkplug #231. That is a wire format, and it is done.compressedarm, so a "zipped JSON" metric is not a distinct type either.One new design question the JSON encoding creates. In
spJv4.0, a JSON-valued metric is either an escaped string or inline JSON. Inline reads better but puts a value with no fixed schema inside a schema-validated payload, and the JSON Schema would have to admit it. This needs deciding ifDocumentgoes ahead; it did not exist as a question when the original decision was recorded.The location half
The agreed set — latitude, longitude, altitude, timestamp — is four values, so it is a composite rather than a primitive. v4 already has
TemplateandPropertySetfor composites, and adding a primitive type per domain concept does not scale: the same argument would bring quaternions, colours and units of measure.The trade is interoperability. A primitive is understood by every implementation without agreement; a well-known Template definition has to be agreed and then recognised by name, which is weaker, but it costs no enum value and no schema change, and it extends to the next domain concept without another round.
Worth noting that
DataTypevalues were just renumbered in #660 to close the gap left by removingText, so anything added now lands at 35 and above, afterCommand.Suggested questions for the working group
content_type = "application/json"on aStringorBytesmetric sufficient, or does aDocumenttype buy something it does not?Documentgoes ahead: escaped string or inline JSON inspJv4.0, and what does the JSON Schema say about it?Related: #575 is the TCK tracker for the DataSet work, not this one; #580 is the TCK tracker for this issue, and like all TCK work it is blocked until #641 lands.