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
Trying to put together a serde crate for Financial Information Exchange ( FIX ) protocol, https://fiximate.fixtrading.org, and encountered a problem that I am not sure how to solve.
Description:
So I would like to generate a bunch of message structures which I can serde both into JSON & FIX format from the same exact structure.
This results in a JSON {"1":"ABC"} & FIX that looks roughly like '1=ABC|' , '|' is not the actual delimiter but here for readability.
Problem:
FIX has two names for each field: a unique Numeric ID and a unique String Name. Example 1 is Same as Account but wire format is always in numeric format. Hence in the above example I can use serde's rename attribute to achieve this. However, I would like to be able to use JSON in both String Name & Numeric ID form.
Deserializing this dual form from JSON does not seem to be a problem and a alias can be used I believe. However, Serializing does not seem to have an option to choose the name, I thought that maybe a pretty_json function can be used but looking at serde_json code I don't believe this Is an option.
Question:
Is it possible at runtime to choose to ignore rename in the serde_json crait or my only option is to do a global string replacement after {"1":"ABC"} json is crated?
In other words I would like to be able to create either:
{"1":"ABC"} or {"Account":"ABC"}
as well as '1=ABC|' or 'Account=ABC|'
Conceptually I think of them as Display vs Debug representation, where the Debug has a full name. perhaps it is a separate SerializeDebug macro, but I am open to any other simple to achieve ideas.
Also I did bump into a is_human_readable method but it seems to only enable a value variant but not the key variant. Is there something similar for the key/field name?
The text was updated successfully, but these errors were encountered:
Trying to put together a serde crate for Financial Information Exchange ( FIX ) protocol, https://fiximate.fixtrading.org, and encountered a problem that I am not sure how to solve.
Description:
So I would like to generate a bunch of message structures which I can serde both into JSON & FIX format from the same exact structure.
Example:
This results in a JSON
{"1":"ABC"}
& FIX that looks roughly like'1=ABC|'
, '|' is not the actual delimiter but here for readability.Problem:
FIX has two names for each field: a unique Numeric ID and a unique String Name. Example
1
is Same asAccount
but wire format is always in numeric format. Hence in the above example I can useserde's
rename attribute to achieve this. However, I would like to be able to use JSON in both String Name & Numeric ID form.Deserializing this dual form from JSON does not seem to be a problem and a
alias
can be used I believe. However, Serializing does not seem to have an option to choose the name, I thought that maybe a pretty_json function can be used but looking at serde_json code I don't believe this Is an option.Question:
Is it possible at runtime to choose to ignore rename in the serde_json crait or my only option is to do a global string replacement after
{"1":"ABC"}
json is crated?In other words I would like to be able to create either:
{"1":"ABC"}
or{"Account":"ABC"}
as well as
'1=ABC|'
or'Account=ABC|'
Conceptually I think of them as Display vs Debug representation, where the Debug has a full name. perhaps it is a separate SerializeDebug macro, but I am open to any other simple to achieve ideas.
Also I did bump into a
is_human_readable
method but it seems to only enable a value variant but not the key variant. Is there something similar for the key/field name?The text was updated successfully, but these errors were encountered: