[yast-devel] Webyast Serialize hash to xml
Hi, when I work on ancestor for rest-service I found interesting problem. How to serialize hash with general keys. Problem is that key could contain prohibited characters and there is no way how to escape it in xml tag (in json it works without problems). I see few solution and want discuss which one is preferred. 1) prohibit general keys and allow only developer defined string: It is how it is done now, as we manually create xml and hash is encoded to different tags ( so eg replace general key => value with [ :key => key, :value => value] ) (it is solved e.g. in time where is map with id_of_timezone => name of timezone) advantage: - easy to do - same as we did it now - easy to use for customer which want use directly rest-service disadvantage: - key must be checked otherwise it could be security problem - more work in rest-service and webclient as hash must be transformer before and after serialization 2) use inlined yaml - serialize hash to yaml and inline to xml. It escaped any problematic patterns advantage: - work out of box - easy to use - no additional transformation disadvantage: - problem for customer which want to use directly rest-service as he must define hash as yaml - on webclient hash must be saved as yaml (easy call hash.to_yaml) which is unintuitive 3) hack webclient Hash.from_xml. I can modify hash.from_xml behavior so if he get hash type it expects array with tags key and value, so result looks same as in 1) and hack it also on backend so it is automatic recognize and just works. advantage - - work out of box - developer doesn't know about it, just works disadvantage - - if customer use nonmodified rails, then it doesn't read correctly as hash (but still can work with it) - need modifications in webclient and rest-service xml serialization and deserialization 4) Use only json - Provide only json in rest-service advantage: - json has better performance then xml, as it is easier to parse and create disadvantage: - no XML, so customer could complain I welcome any comments about solutions or propose of new solution. Josef -- Josef Reidinger YaST team maintainer of perl-Bootloader, YaST2-Repair, webyast (language,time,basesystem,ntp) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (1)
-
Josef Reidinger