Mailinglist Archive: yast-devel (77 mails)

< Previous Next >
[yast-devel] Webyast Serialize hash to xml
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Fri, 11 Dec 2009 10:14:08 +0100
  • Message-id: <200912111014.08563.jreidinger@xxxxxxx>
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)

- easy to do
- same as we did it now
- easy to use for customer which want use directly rest-service

- 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

- work out of box
- easy to use
- no additional transformation

- 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

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

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

4) Use only json - Provide only json in rest-service

- json has better performance then xml, as it is easier to parse and create

- no XML, so customer could complain

I welcome any comments about solutions or propose of new solution.


Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, webyast
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages