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.
Decide before calling
Read the versioned contract and the supported scope below. Reuse json-array-count@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use json-array-count@1.0.0 for json array count. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
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 align: Align two JSON arrays with duplicate-safe occurrence pairs and deterministic LCS tie-breaking.
- 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 three way merge: Merge base, left and right JSON arrays, returning deterministic output and explicit conflicting edit regions.
- JSON array unique: Deduplicate a JSON array by structural equality, keeping first-seen order.
- JSON keyed resolution apply: Apply explicit choices to every keyed-array merge conflict and return the fully reconstructed JSON array.