Why is DAML returning a text whild I am putting a decimal as input

I am using DAML with Fabric as a ledger

When I am creating a contract on the ledger. I am giving

{
“templateId”: “Example”,
“payload”: {
“admin”: “Admin”,
“name”:“License”,
“version”:1.0
}
}

Now, when I am retrieving, the contract from the ledger.

{
“templateIds”: [
“Example”
],
“query”: {
“name”:“License”
}
}

I am getting :-
{
“result”: [
{
“agreementText”: “”,
“contractId”: “00686ba01bc84341c21af4c88eaacfeb43d1511f4c4c6711897323f95cf9b711b4”,
“observers”: [],
“payload”: {
“admin”: “Admin”,
“name”: “License”,
“version”: “1”
},
“signatories”: [
“Admin”
],
“templateId”: “9821afd39bdf127fde479280cebaf5816e5accac7b038f225952e003c055c4c7:Example”
}
],
“status”: 200
}

Why am I getting version as text instead of as decimal

1 Like

The JSON API always returns numbers as strings. This is a choice made because, while the JSON spec does not specify any specific numeric representation, a lot of JSON implementations assume JSON numbers are JavaScript numbers and thus decode them to floating points, potentially losing precision.

Returning a string puts the user in control of the decoding and thus lets the user choose whether to lose precision or not.

3 Likes