Skip to content

Allow JSON null in JSON-able values - #873

Merged
mristin merged 1 commit into
mainfrom
mristin/Allow-JSON-null-in-JSON-able-values
Oct 31, 2026
Merged

mristin merged 1 commit into
mainfrom
mristin/Allow-JSON-null-in-JSON-able-values

Conversation

@mristin

@mristin mristin commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

In value-only JSON, an empty element of a SubmodelElementList is serialized as null to preserve the list indices (e.g., [10, null]), but we rejected null in JSONValue. We now include None in JSONValue, so a null may appear at any depth, including as the value itself.

An optional JSONValue holding a null counts as absent, and we omit the key on serialization in all the targets.

In the meta-model, is None and is not None over a non-optional JSONValue (a guarded index or a required property) now check for a JSON null:

m is not None and "k" in m and m["k"] is not None

An unguarded key index still can not be checked for nullness since it would conflate a missing key with a null.

JSON schema includes {"type": "null"}, and XML-RPC uses the widespread <nil/> extension, reflected in the XSD.

In TypeScript, we now tell success from failure in Either by the error alone, so that null can be a successfully parsed value.

@mristin
mristin force-pushed the mristin/Allow-JSON-null-in-JSON-able-values branch 2 times, most recently from 45f63fb to e76e7cc Compare October 30, 2026 16:27
@coveralls

coveralls commented Oct 30, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 41188388014

Coverage increased (+0.02%) to 90.251%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: Could not be determined — this PR's diff is too large for GitHub to return (406 error at GitHub).
  • 888 coverage regressions across 27 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

888 previously-covered lines in 27 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
aas_core_codegen/intermediate/type_inference.py 196 91.53%
aas_core_codegen/csharp/transpilation.py 126 83.21%
aas_core_codegen/cpp/transpilation.py 96 82.56%
aas_core_codegen/java/transpilation.py 88 83.72%
aas_core_codegen/xsd/main.py 73 77.99%
aas_core_codegen/intermediate/_types.py 48 95.23%
aas_core_codegen/csharp/lib/_generate_jsonization.py 25 96.14%
aas_core_codegen/jsonschema/main.py 23 84.28%
aas_core_codegen/csharp/lib/_generate_xmlization.py 22 96.26%
aas_core_codegen/java/lib/_generate_types.py 21 88.33%

Coverage Stats

Coverage Status
Relevant Lines: 51490
Covered Lines: 46470
Line Coverage: 90.25%
Coverage Strength: 2.71 hits per line

💛 - Coveralls

@mristin
mristin force-pushed the mristin/Allow-JSON-null-in-JSON-able-values branch from e76e7cc to a2583e6 Compare October 30, 2026 17:01
In value-only JSON, an empty element of a SubmodelElementList is
serialized as ``null`` to preserve the list indices (e.g.,
``[10, null]``), but we rejected null in ``JSONValue``. We now include
``None`` in ``JSONValue``, so a null may appear at any depth, including
as the value itself.

An optional ``JSONValue`` holding a null counts as absent, and we omit
the key on serialization in all the targets.

In the meta-model, ``is None`` and ``is not None`` over a non-optional
``JSONValue`` (a guarded index or a required property) now check for
a JSON null:

    m is not None and "k" in m and m["k"] is not None

An unguarded key index still can not be checked for nullness since it
would conflate a missing key with a null.

JSON schema includes ``{"type": "null"}``, and XML-RPC uses
the widespread ``<nil/>`` extension, reflected in the XSD.

In TypeScript, we now tell success from failure in ``Either`` by
the error alone, so that ``null`` can be a successfully parsed value.
@mristin
mristin force-pushed the mristin/Allow-JSON-null-in-JSON-able-values branch from a2583e6 to e99db58 Compare October 31, 2026 09:21
@mristin
mristin merged commit 20606a9 into main Oct 31, 2026
5 checks passed
@mristin
mristin deleted the mristin/Allow-JSON-null-in-JSON-able-values branch October 31, 2026 09:54
mristin added a commit to eclipse-aascw/aas-core3.2-python that referenced this pull request Oct 31, 2026
We update to aas-core-codegen 0.0.27rc5 and to the latest
aas-core-meta 796ae74, and re-generate the code. The meta-model file
itself is pinned to 543f3c0, the last commit which changed ``v3_2.py``.

The relevant changes are:

* JSON-able values admit JSON null (``None``) at any depth
  ([aas-core-codegen#873], [aas-core-meta#416]), *e.g.*, for an empty
  element of a submodel element list in the ValueOnly JSON. An optional
  JSON-able property holding a null counts as absent. In XML-RPC, a null
  is written as ``<nil/>``.

* The results of ``GetSubmodelsValueResult`` and
  ``GetSubmodelElementsValueResult`` are arrays of ValueOnly JSON
  objects instead of a single JSON object ([aas-core-meta#415]). We
  deviate from the OpenAPI since V3.0.4 ([aas-specs-api#414]), which we
  suspect to be buggy, and follow [BaSyx Go] and the prose of
  the specification.

[aas-core-codegen#873]: eclipse-aascw/aas-core-codegen#873
[aas-core-meta#416]: eclipse-aascw/aas-core-meta#416
[aas-core-meta#415]: eclipse-aascw/aas-core-meta#415
[aas-specs-api#414]: admin-shell-io/aas-specs-api#414
[BaSyx Go]: https://github.com/eclipse-basyx/basyx-go-components
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants