Object Key Rename Map

Simultaneously rename own JSON object keys from an explicit map; reject collisions with renamed or untouched keys.

Description

Simultaneously rename own JSON object keys from an explicit map; reject collisions with renamed or untouched keys.

Renaming object keys needs collision checks so a destination name cannot silently overwrite another value. A rename map can also leave unrelated fields untouched.

When to use this tool

Simultaneously rename own JSON object keys from an explicit map; reject collisions with renamed or untouched keys.

  • Prepare the supplied objectJson, oldKeys, newKeys fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter objectJson, oldKeys, newKeys. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.object. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Require aligned oldKeys/newKeys and distinct oldKeys. Rename matching own entries simultaneously, retain other names, then reject duplicate or blank resulting keys before building the output object.1

Input fieldMeaning and representationAccepted input
objectJsonJSON text, entered as one text field. The decoded structure is illustrated below; it is not a separate file.Text
oldKeysold keys.At most 128 strings, each at most 128 UTF-16 code units
newKeysnew keys.At most 128 strings, each at most 128 UTF-16 code units

For the JSON text fields, the following decoded structures show the example records before they are serialized into input strings. Keep field names, list nesting and value types as shown.

json
[
  {
    "field": "objectJson",
    "decoded": {
      "a": 1,
      "b": 2
    }
  }
]
Output fieldInterpretation
resultObject containing the named outputs below.
result.objectThe object value under the stated formula or text convention.
json
{
  "input": {
    "objectJson": "{\"a\":1,\"b\":2}",
    "oldKeys": [
      "a"
    ],
    "newKeys": [
      "x"
    ]
  },
  "output": {
    "result": {
      "object": {
        "x": 1,
        "b": 2
      }
    }
  }
}

Limitations and assumptions

  • Missing old names have no effect. Renames are shallow and simultaneous rather than sequential; the helper's distinct-key validation also rejects an empty resulting key collection.
  • Decoded JSON is bounded to 20,000 nodes and 32 nesting levels; record arrays have at most 128 records. Parsed number values use JavaScript floating point rather than arbitrary-precision decimal arithmetic.
  • Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
  • Ordinary string lists have at most 128 entries of at most 128 code units each; numeric lists and matrices have separate bounded size checks. Nonfinite results and excessively large serialized outputs are rejected.
  • Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.

Alternative or Complementary methods

For document-wide requirements, combine these structural inventories with an explicit JSON Schema. Preserve the distinction between missing properties and null values, and between numbers and numeric-looking strings when building joins or indexes.

References

  1. Tool behavior and example: Object Key Rename Map — tool.io

Similar or alternative tools

  • Object Key Prefix Partitioner

    Partition own JSON object members by exact literal key prefix; does not strip prefixes or interpret patterns.

  • Ordered Object Key Selector

    Select own object members in explicit order as entries, avoiding JavaScript integer-key reorder ambiguity; report absent names separately.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies