Description
Select one JSON object member under an explicit default policy.
JSON distinguishes a member's absence, explicit null and other scalar or container values. Source number syntax differs from finite machine-number range, and reserializing a parsed value can change its spelling. Record delimiters also belong to a stream convention rather than automatically forming one valid JSON document.
Select one JSON object member under an explicit default policy.
When to use this tool
Use JSON Single Member Default Policy when you already have objectJson, memberName, defaultScalarJson, nullUsesDefault and need to select one JSON object member under an explicit default policy.
How to use the tool and how it works
- Enter objectJson, memberName, defaultScalarJson, nullUsesDefault. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read selectedJson, usedDefault. Inspect usedDefault before interpreting the associated values.
Parse an object and a scalar default; require the object to be a portable JSON value and default null, text, Boolean or finite number. Look up an own member; use default if absent or if nullUsesDefault and its value is null. Serialize the selected value as JSON text.1
JSON objects contain named values, which can themselves be structured values. A scalar-only fallback therefore does not imply that every selected member is scalar.2
| Input field | Meaning and units | Accepted input |
|---|---|---|
| objectJson | Object Json | Required. Text; maximum UTF-16 length 8192. |
| memberName | Member Name | Required. Text; maximum UTF-16 length 8192. |
| defaultScalarJson | JSON null, boolean, number or string only; a selected existing member may also be an object or array. | Required. Text; maximum UTF-16 length 8192. |
| nullUsesDefault | If true, a present null uses the fallback; otherwise only a missing own member does. | Required. Boolean. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| selectedJson | Selected Json | Required. Text; maximum UTF-16 length 8192. |
| usedDefault | Used Default | Required. Boolean. |
{
"input": {
"objectJson": "{\"a\":null}",
"memberName": "a",
"defaultScalarJson": "3",
"nullUsesDefault": false
},
"output": {
"selectedJson": "null",
"usedDefault": false
}
} Limitations and assumptions
- A present null differs from absence, and a selected member may be an object or array. No schema validation, inherited lookup or default insertion into the original object occurs.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
Alternative or Complementary methods
Parse and validate the complete intended JSON schema or record stream when structural conformance matters. Preserve original source text when lexical spelling is significant, and decide explicitly whether absent and null members should share a default.
References
Similar or alternative tools
- JSON Scalar Append Delimiter Choice
Serialize one JSON scalar and append a selected record delimiter.
- JSON Number Plus Sign Rejection
Check JSON number-token syntax separately from a leading-plus flag.