Fix serialization of empty arrays to preserve semantic information


- Empty arrays should be serialized to JSON output when they are
explicitly set, even if they contain zero elements.

OpenAPI 3.1 uses JSON Schema (2020-12) for validation.
According to JSON Schema specification:
* An empty array [] is a valid value for array type
* Required array fields are satisfied by the presence of the key,
  regardless of array size (including empty arrays)
* Empty arrays have semantic meaning: "no items" is different from
  "field not specified"

See JSON Schema array validation:
https://json-schema.org/understanding-json-schema/reference/array

The old implementation used `m_field.size() > 0` checks in both
asJsonObject() and isSet() methods. This caused two problems:

1. Empty arrays were silently dropped during serialization because
   size() == 0 evaluated to false, preventing the field from being
   added to the JSON output.

2. isSet() returned false for empty arrays, incorrectly indicating
   that the field was not set, when in fact an empty array was
   explicitly provided.

Example scenario (from test case):
- Client receives: {"exporting-countries": []}
- Client internally: field is set, array is empty (valid)
- Client serializes back: {} (field dropped - WRONG!)
- Server receives: missing field (ambiguous - could mean "unknown")

This is problematic because:
* "exporting-countries": [] clearly means "no exporting countries"
* Omitting the field could mean "not specified" or "unknown"
* The client changes the semantic meaning during round-trip

This fix changes the condition from `m_field.size() > 0` to
`m_fieldIsSet` in both methods, ensuring:
* Empty arrays are preserved in JSON output when explicitly set
* isSet() correctly returns true for empty arrays
* Semantic information is maintained through serialization
* Round-trip consistency: deserialize -> serialize produces same JSON

Task-number: QTBUG-145412
Pick-to: 6.11
Change-Id: I2a1f4621aceb800edda555d066dc5503800e9405
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
commit9bac0ea082a1b0ea86d7fdf27b05d9b5abe2a828
parent24d5dcc7862475d8360e2463d916b9e436ba3a40
authorTatiana Borisova <tatiana.borisova@qt.io>
committerTatiana Borisova <tatiana.borisova@qt.io>
commit timeTue, 7 Apr 2026 15:57:51 +0200