Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON don't serialize Numerics as String #436

Closed
mhrimaz opened this issue Jan 22, 2024 · 3 comments · Fixed by aas-core-works/aas-core3.0-python#14
Closed

JSON don't serialize Numerics as String #436

mhrimaz opened this issue Jan 22, 2024 · 3 comments · Fixed by aas-core-works/aas-core3.0-python#14

Comments

@mhrimaz
Copy link

mhrimaz commented Jan 22, 2024

When I have a property that is defined as a numeric type, the json serialization serialize it as numeric but it should be a string.

prop = aas_types.Property(id_short="Weight",
                          value=1,
                          value_type=aas_types.DataTypeDefXSD.DOUBLE)
print(json.dumps(aas_jsonization.to_jsonable(prop),indent=2))

output is:

{
  "idShort": "Weight",
  "valueType": "xs:double",
  "value": 1,
  "modelType": "Property"
}

but should be:

{
  "idShort": "Weight",
  "valueType": "xs:double",
  "value": "1",
  "modelType": "Property"
}

SDK detail version: Python Version: 1.0.0rc3

@mristin
Copy link
Contributor

mristin commented Jan 22, 2024

Hi @mhrimaz ,
We do not implement runtime type guards by design. Please run mypy on your code to avoid such bugs.

Btw., this is true for all attriputes, not only Property.value.

@mristin mristin closed this as completed Jan 22, 2024
@mristin
Copy link
Contributor

mristin commented Jan 22, 2024

I'm reopening the issue as this design decision has not been properly documented.

@mristin
Copy link
Contributor

mristin commented Jan 24, 2024

The design decision has been properly documented in: aas-core-works/aas-core3.0-python#14

Thanks again for reporting, @mhrimaz !

@mristin mristin closed this as completed Jan 24, 2024
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 a pull request may close this issue.

2 participants