Closed janusdotai closed 1 year ago
Hey @janusdotai,
Thank you for bringing the issue to my attention. I have now released a fix for it. I considered your suggestion to use a symbol to escape the reserved keywords, but I thought it would be better if users chose the names themselves.
To achieve this, I have included a new record parameter in the toText
and fromText
functions. This parameter has a field called renameKeys
, which takes an array of Text
tuples for mapping field keys in records and variants to their new names. I have also updated the mops version and added an example in the readme.
Please let me know if there are any issues with the fix.
Cheers!
awesome thanks!
Greetings,
Thanks for this wonderful library. I'm using it to pull JSON in motoko from rosetta and in the response some of the named object properties are of the word "type" which happens to be a reserved keyword in motoko thus the compiler complains.
How do you go about handling this case? In other languages such as c# they use the "@" symbol infront of the property eg @type or @class
/100089505/a16b6bf6-b6f0-4bbe-97d2-7160efc1efa6)