JSON Validation Report Sample
This sample report shows a CodeAva JSON validation run on an API order payload. Three errors were found — a syntax error (trailing comma), a missing required field (customerId), and a type mismatch (quantity as string). One warning flags excessive decimal precision on a price field. Three structural checks passed.
3
errors found
Overall Score
3
Parse errors
1
Warnings
3
Passed checks
7
Total checks
Syntax error: trailing comma
criticalA trailing comma was found after the last property in the items array. JSON does not allow trailing commas — this will cause a parse failure in any strict JSON parser.
Line 18:
"items": [
{ "sku": "SHOE-42", "quantity": 2, "price": 89.99 },
{ "sku": "SOCK-M", "quantity": 3, "price": 4.99 }, ← trailing comma
]
Fix: Remove the comma after the last array element.Missing required field: customerId
criticalThe customerId field is required by the /api/orders schema but is absent from this payload. The order cannot be attributed to a customer account and will be rejected at the validation layer.
Expected schema:
{
"customerId": "string (required)",
"items": [...],
"shippingAddress": {...}
}
Payload received:
customerId field is absent entirely.
Fix: Include "customerId": "cust_8xR9mNq" in the root object.Wrong type: quantity should be number, received string
criticalThe quantity field in the second line item is a JSON string ("3") instead of a number (3). Strict schema validation will reject this and a type coercion bug could cause silent inventory miscounts.
Received:
{ "sku": "SOCK-M", "quantity": "3", "price": 4.99 }
^^^ string
Expected:
{ "sku": "SOCK-M", "quantity": 3, "price": 4.99 }
^ number
Fix: Remove the quotes around the quantity value.price field has excessive decimal precision
warningOne price value is specified to 4 decimal places (89.9999). While valid JSON, currency values should be expressed to exactly 2 decimal places to avoid floating-point rounding issues in downstream financial calculations.
Received: "price": 89.9999
Suggested: "price": 90.00
Note: For precise currency arithmetic, consider storing prices
as integers (cents) rather than floating-point decimals.Recommended fixes
Remove the trailing comma on line 18
Delete the comma after the last element of the items array. Most code editors with JSON support will flag this automatically — enable JSON validation in your editor settings.
Fix quantity type from string to number
Remove the quotes around the quantity value: "quantity": 3 not "quantity": "3". Consider adding a schema validator (e.g. Zod, Joi, or JSON Schema) to catch type errors automatically.
Add customerId to the request payload
Pass the authenticated customer ID when constructing the order payload on the client. This is typically available from the auth context or session at the time of checkout.
Add schema validation to your API layer
Integrate a schema validation library such as Zod or Joi at the API route entry point. Validate all incoming payloads before processing to catch these errors early with structured error responses.
Run this audit on your own project
This is a sample report. Get your own scored results by pasting a URL or code snippet.