Skip to main content
Increments the numeric value at the specified path by a given amount. Supports both integers and floating-point numbers.

Usage

Arguments

key
string
required
The key containing the JSON document
path
string
required
JSONPath expression pointing to the numeric value to increment
value
number
required
The increment value. Can be positive (to increase) or negative (to decrease). Supports both integers and floating-point numbers.

Response

result
(number | null)[]
An array of numbers representing the new value at each matching path after the increment. Returns null for paths that don’t exist or aren’t numeric values.

Examples

Increment an integer

Decrement by using negative value

Increment a floating-point number

Increment nested numeric value

Increment multiple values (wildcard path)

Increment with decimal precision

Track counter

Handle non-existent paths

Handle non-numeric values

JSONPath Syntax

  • $.number - Increment a top-level number
  • $.nested.number - Increment a nested number
  • $.object.count - Increment a number within an object
  • $..count - Increment all matching numbers recursively
  • $.items[*].quantity - Increment numbers within each item

Notes

  • The operation is atomic - the increment happens as a single operation
  • Both integers and floating-point numbers are supported
  • Negative values can be used to decrement
  • Returns null if the path doesn’t exist or doesn’t point to a numeric value
  • When using wildcard paths, the operation is performed on all matching numeric values
  • Floating-point arithmetic follows standard IEEE 754 rules

See Also