Skip to content

Add new primitive types for location and generic JSON #444

Open
0 of 1 issue completed
Open

Description

@wes-johnson

This came from a list of suggestions in #432.

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    spec feature
    on Apr 13, 2023
  2. added this to the M2 milestone on Jun 27, 2023
  3. ravisubramanyan commented on Sep 19, 2023

    @ravisubramanyan

    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 ?

  4. self-assigned this
    on Sep 14, 2026
  5. added a commit that references this issue on Nov 25, 2026
  6. wes-johnson commented on Nov 25, 2026

    @wes-johnson
    ContributorAuthor

    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

    1. Split location and generic JSON into separate issues?
    2. For JSON: is content_type = "application/json" on a String or Bytes metric sufficient, or does a Document type buy something it does not?
    3. If Document goes ahead: escaped string or inline JSON in spJv4.0, and what does the JSON Schema say about it?
    4. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

M2spec feature

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions