Skip to content

Main content

Typed Tuple Key Encoder

Encode a JSON scalar tuple as count plus length-prefixed typed scalar keys, avoiding concatenation ambiguity and preserving component types.

Loading tool…

Description

Encode a JSON scalar tuple as count plus length-prefixed typed scalar keys, avoiding concatenation ambiguity and preserving component types.

An opaque key’s representation can affect equality and ordering even when its underlying value is unchanged. Delimiter joining can be ambiguous, fixed-width padding can preserve numeric order within agreed bounds, and typed length-prefix framing keeps scalar types distinct. Lengths in this family count UTF-16 code units unless a different unit is stated.

Encode a JSON scalar tuple as count plus length-prefixed typed scalar keys, avoiding concatenation ambiguity and preserving component types.

When to use this tool

Use this tool to encode a JSON scalar tuple as count plus length-prefixed typed scalar keys, avoiding concatenation ambiguity and preserving component types.

How to use the tool and how it works

  1. Enter valuesJson using the field definitions below. For JSON text, serialize the explicit records in the shown shape.
  2. Run the operation. Correct input errors before interpreting an output.
  3. Read result.key. Use the ordering, boundary rules and absence conditions described below.

Encode each JSON scalar with its type tag, then prepend tuple count and each encoded member’s UTF-16 length to form one unambiguous tuple key.1

Input fieldMeaning and unitsAccepted input
valuesJsonJSON array of scalar values: strings, finite numbers, booleans or null. Nested arrays and objects are rejected; mixed scalar types are allowed.Text, at most 8,192 UTF-16 code units; the operation’s grammar also applies.

These are the decoded structures used in the example’s JSON text fields. Supply the corresponding serialized JSON strings as input.

json
{
  "valuesJson": [
    1,
    "1",
    null
  ]
}
Output fieldInterpretation
resultObject containing the named fields below.
result.keyEncoded, normalized-affix or padded key under the stated framing/ordering convention.
json
{
  "input": {
    "valuesJson": "[1,\"1\",null]"
  },
  "output": {
    "result": {
      "key": "t:3:3:n:15:s:1:12:z:"
    }
  }
}

Limitations and assumptions

  • Only finite JSON scalars are accepted; this is reversible framing rather than encryption or hashing.
  • JSON numeric scalars use JavaScript floating-point numbers. Supply a JSON string when an identifier’s exact large-integer digits must be preserved; strings and numbers remain distinct scalar types.
  • String framing and alphabet digits use UTF-16 code units, not bytes or grapheme clusters. Exact integer text accepts a signed decimal spelling of at most 256 digits before operation-specific range checks.
  • Every declared top-level input field is required and unexpected fields are rejected. Ordinary strings are limited to 8,192 UTF-16 code units and lists to 128 entries, with tighter operation-specific bounds where stated. JSON text has bounded nesting and node counts.
  • Numeric outputs must be finite and no larger in absolute magnitude than the safe-integer limit; operations returning exact large integers use decimal text. Positions are zero-based and spans end exclusively unless the operation explicitly states a different convention.

Alternative or Complementary methods

Use typed framing when distinct scalar types or tuple boundaries must remain distinguishable. Keep alphabet, width, normalization and numeric bounds consistent between producers and consumers.

References

  1. Tool behavior and example: Typed Tuple Key Encoder — tool.io

Similar or alternative tools

  • Typed Scalar Key Encoder

    Encode one JSON scalar into a type-tagged reversible key with explicit UTF-16 string length; rejects arrays/objects and preserves numeric negative zero.

  • Typed Tuple Key Decoder

    Decode the bounded typed tuple key dialect, rejecting incomplete/trailing fields and preserving scalar types; no arbitrary JSON object keys.