New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a method like indented to XML serialization #612
Comments
did you mean remove Gson result.use(xml()).from(object).indent().serialize() If so, I don't like this... I'd prefer +human readable output by default. |
and it will break compability on it's released version. |
ops.. forgot about Gson (you are talking about XStream). |
I think the just impact is on tests and don't is big, but is really too specific. So may close this issue. 😃 |
what do you think @garcia-jj and @lucascs? |
@Turini, we already have this discussion 2 or 3 years ago when develop Json and XML are made to machine exchange, not to humans read. With no If some dev needs to debug, there are many tools that already do this job |
so why it appears formatted until now? Or it does not? (I'm really not sure) |
Good question. I'm not in my computer right now. But later I can see this |
It's appear just formatted. |
yeap... this is my point. Until now XML output is formatted. |
May a bug. As you see we don't have "without indentation" method, only Can you do a test to us? Create two methods that serializes to XML, one And the same with json. |
I'm not at home now, but after I'll do this. |
Hmm, now I'm on a computer :happy:. I remember that I ask this behavior on dev mailing list. And after a long discussion we decide that all serializations should be without indentation. Why? Because JSON and XML is just to machine exchange, not to be user readable. Without indentation we have more performance when download the JSON and XML. For a XML or Json, spaces/tabs/linebreaks is usefulness. And now all browsers have native tools to pretty debug JSON or XML. As you see there is no method to remove indentation, only methods to add indentation. Because by default serialization isn't indented. I did this code in vraptor 3, so I think that this code was missed. See this: caelum/vraptor@9a11124 Take a look in But I think that we can change this behavior now, because this change wont break applications because spaces/tabs/linebreaks are not relevant to JSON/XML processors (it's just ignored). But can impact is users have tests comparing strings, so we can add a text explain this change in release notes. |
I found the thread :) https://groups.google.com/forum/#!topic/caelum-vraptor-dev/FpVYFlzMNMI But I think that we only change for JSON, not to XML :( |
Can we have both worlds? In production the code is not identeted, and in My other sugestion is not ident by default at all, like V3. Change the Mário do Amaral Gonçalves 2014-06-18 11:35 GMT-03:00 Otávio Garcia notifications@github.com:
|
Yes Mário, this is my point. Today we have |
Mário, what you think about a option like |
It's a good idea @garcia-jj ! 👍 |
i think we can create a environment option. what do you think? |
I prefer something like |
I prefer the Felipe approach. Something like identXml=false/identJson=false What I mean is this options shouldn't be in the code, if the purpose is Mário do Amaral Gonçalves 2014-06-18 12:25 GMT-03:00 Renan Montenegro notifications@github.com:
|
All vraptor configuration are located at Java code. Can be easily Just my opinion: properties can forgettable, and dev must see the key in And I can add only in places I want. In the properties all places will I prefer method, but I don't see a big problem to use property. But I May we can invite more people to discuss about. @Turini @lucascs @rponte |
Why not both? Having these properties in configuration file is good if you have to deal with multiple environments, so you just need to change the file in build or deploy-time, for example. But I agree with @garcia-jj that having an API is also a good idea and is the VRaptor way of developing. |
If we use both, |
Good idea @rponte. 👍 |
For me makes sense @garcia-jj ! |
text configuration usually takes precedence over programatic/annotation configuration... so you can create a properties/xml for each environment and don't have to recompile a jar. I wouldn't put the indentedIf method, though... |
@lucascs when I wrote the 1st piece of this code I think that same you. |
Reopen to add support for environment. |
|
Nope. |
I think that a good idea would be MockSerializationResult doesn't indent the result either. What do you think ? |
Redundant, because user can add this config via environment. (test.properties when use tests). |
Oh, really, will be via environment. Thanks |
I thought about this because Sorry for the doubts. |
Sorry, I was wrong. |
Implemented, and will be available in the next release. Thank you, people, to your suggestions. |
Allways the
result.use(xml()).from(object).serialize()
brings in a pretty format what may difficult the tests and we may don't want for any reason.What about create some method like
indented
ofJSONSerialization
?The text was updated successfully, but these errors were encountered: