JSON array count
json-array-count · version 1.0.0 · JSON & JSONL · free, no key needed
Count structural occurrences in a JSON array in first-seen order.
Use when you need to: json array count · count json values · json value histogram.
Supported
- json array count
- count json values
- json value histogram
Not supported
- sort by count
- reference identity
Behavior
- Accept only JSON values: null, boolean, finite number, string, array, and plain objects.
- Reject NaN, Infinity, -Infinity, undefined, BigInt, functions, symbols, Date, Map, Set, RegExp, boxed primitives, Buffer, and sparse holes.
- Canonicalize -0 to 0.
- Objects may have null or Object.prototype; use own enumerable string keys only.
- Treat __proto__, constructor, and toString as ordinary own keys. Never mutate Object.prototype.
- Output objects must be Object.create(null). Deep-clone all returned JSON values.
- Bound walk: max depth 32, max nodes 10000, max UTF-8 JSON bytes 250KiB of the input document string if provided as text; when json is already a value, bound the walked node count and depth.
- items must be a JSON array.
- Equality as json-deep-equal. First-seen order.
- Each output item is { value: clone, count } with null-prototype objects.
Input
items(array of any, required): max items 10000
Output
items(array of object, required)items_in(integer, required)unique(integer, required)
Limits
- max json depth: 32
- max json nodes: 10000
- max items: 10000
Example
Request input:
{
"items": [
1,
1,
"1"
]
}
Response:
{
"result": {
"items": [
{
"value": 1,
"count": 2
},
{
"value": "1",
"count": 1
}
],
"items_in": 3,
"unique": 2
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "json-array-count",
"version": "1.0.0",
"input": {
"items": [
1,
1,
"1"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/json-array-count/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"items":[1,1,"1"]}'
The machine-readable contract is at /v1/tools/json-array-count/versions/1.0.0.
CLI
node cli.mjs run json-array-count 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- JSON array filter equals: Filter JSON array objects where a key equals a specific value.
- JSON array group count: Group an array of JSON objects by exact keys and return the count.
- JSON array unique: Deduplicate a JSON array by structural equality, keeping first-seen order.
- Array to JSONL: Serialize an array of JSON-safe values as JSON Lines text.
- JSON array anti join: Anti join two JSON arrays of objects on exact keys.
- JSON array concat: Concatenate multiple JSON arrays of objects into one.