You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normally the JSON representation can be customised in the default member function of MZNJSONEncoder, but because IntEnum inherits from int, the representation is part of the base types of JSONEncoder that is directly implemented in the encoder library (and a C backend)
This is incorrect as an input for a MiniZinc enum, where a JSON object {"e": "some_name"} is expected and an integer will not be accepted.
workaround
A current workaround is to use an Enum in Python, or to use the actual matching integers in the MiniZinc model.
possible solutions
The following solutions could be considered:
A more customisable JSONEncoder that gives us more freedom to change the JSON representation of IntEnum
Change the data when it is set to be in the required format.
The last solution seems more likely, as I'm currently unaware of a better JSON Encoder alternative and several attempts are the second method have failed.
The text was updated successfully, but these errors were encountered:
The standard
JSONEncoder
that is used to create the JSON input for a MiniZinc model ensures that anIntEnum
is always represented using its integer representation: https://github.com/python/cpython/blob/3.9/Lib/json/encoder.py#L309-L313Normally the JSON representation can be customised in the
default
member function ofMZNJSONEncoder
, but becauseIntEnum
inherits fromint
, the representation is part of the base types ofJSONEncoder
that is directly implemented in the encoder library (and a C backend)This is incorrect as an input for a MiniZinc enum, where a JSON object
{"e": "some_name"}
is expected and an integer will not be accepted.workaround
A current workaround is to use an
Enum
in Python, or to use the actual matching integers in the MiniZinc model.possible solutions
The following solutions could be considered:
IntEnum
_intstr
function (both in the Python and C implementation): https://github.com/python/cpython/blob/3.9/Lib/json/encoder.py#L271The last solution seems more likely, as I'm currently unaware of a better JSON Encoder alternative and several attempts are the second method have failed.
The text was updated successfully, but these errors were encountered: