pretty-print

Putting each attribute on a new line during xml serialization

旧巷老猫 提交于 2019-12-31 02:46:24
问题 Lets say I have a DOM object (or a string containing xml). Is it in any way possible to serialize the xml in such a way that each attribute appears on a new line? This is the output I want: <parent> <anElement attrOne="1" attrTwo="2" attrThree="3" /> </parent> Preferred if the solution a part of the standard java api, but I suspect such a feature is not available in there, or am I wrong? I found a property for a serializer in the .NET Framework, called NewLineOnAttributes. What I am searching

Multi-line pretty-printing of (nested) collections in Java

萝らか妹 提交于 2019-12-29 07:33:08
问题 I want to be able to (pretty-)print the contents of my maps. They should have newlines and indentation rather than on a single line; ignoring the toString methods of collections/iterables/etc; and recursing into nested collections. This is especially of interest for me regarding maps. I suppose JSON'ing might be relevant, but I don't want to go that far, or at least - I don't want my code to have to know about JSON just for me to pretty-print it. What are my options (other than writing this

When using Spring MVC for REST, how do you enable Jackson to pretty-print rendered JSON?

▼魔方 西西 提交于 2019-12-28 08:06:09
问题 While developing REST services using Spring MVC, I would like render JSON 'pretty printed' in development but normal (reduced whitespace) in production. 回答1: If you are using Spring Boot 1.2 or later the simple solution is to add spring.jackson.serialization.INDENT_OUTPUT=true to the application.properties file. This assumes that you are using Jackson for serialization. If you are using an earlier version of Spring Boot then you can add http.mappers.json-pretty-print=true This solution still

When using Spring MVC for REST, how do you enable Jackson to pretty-print rendered JSON?

半世苍凉 提交于 2019-12-28 08:05:04
问题 While developing REST services using Spring MVC, I would like render JSON 'pretty printed' in development but normal (reduced whitespace) in production. 回答1: If you are using Spring Boot 1.2 or later the simple solution is to add spring.jackson.serialization.INDENT_OUTPUT=true to the application.properties file. This assumes that you are using Jackson for serialization. If you are using an earlier version of Spring Boot then you can add http.mappers.json-pretty-print=true This solution still

How to pretty print a matrix in Octave?

三世轮回 提交于 2019-12-24 06:38:10
问题 I want to create a pretty printed table from a matrix (or column vector). For Matlab there are several available functions that can do this (such as printmat, array2table , and table ), but for Octave I cannot find any. So instead of: >> a = rand(3,2)*10; >> round(a) ans = 2 10 1 3 2 1 I would like to see: >> a = rand(3,2)*10; >> pretty_print(round(a)) THIS THAT R1 2 10 R2 1 3 R3 2 1 How can I produce a pretty printed table from a matrix? (Any available package to do so?) UPDATE After trying

Handling json pretty print param in ASP.NET Web API application in HttpConfiguration instance

淺唱寂寞╮ 提交于 2019-12-24 04:43:05
问题 I need to add and handle optional "pretty" parameter in my ASP.NET Web API application. When user sends "pretty=true", the application response should look like a human-readable json with indentations. When user sends "pretty=false" or does not send this parameter at all, he must get json with no space symbols in response. Here's what I have: Global.asax.cs public class WebApiApplication : HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas();

Can I configure Jackson JSON pretty printing from annotations or from Spring MVC controller?

天涯浪子 提交于 2019-12-24 00:34:56
问题 I'm using Jackson 1.9.6 (codehaus) for JSON serialization of my response bodies in a Spring MVC application, and I'm having trouble finding a way to configure pretty printing. All of the code examples I've been able to find (like this and this) involve playing with an instantiation of ObjectMapper or ObjectWriter , but I don't currently use an instantiation of these for anything else. I wouldn't even know where to put this code. All of my Jackson configurations are taken care of by annotating

Pretty Print JSON generated with a jbuilder template in Rails 3.2.8

ⅰ亾dé卋堺 提交于 2019-12-23 11:52:34
问题 Anyone have a way to pretty print JSON output from jbuilder? I can pretty print JSON generated within a controller action with something like: JSON.pretty_generate(some_json_object) but once I pass off to a jbuilder template, I'm not aware of a way to have that output pretty printed. Right now, my action method's render statement is simple: render formats: :json And this successfully forces a rendering with jbuilder, regardless of input format type specified (which is my desired behavior).

Colored var_dump() and errors

时光怂恿深爱的人放手 提交于 2019-12-23 09:38:02
问题 How can I set style to var_dump() function and PHP errors style, like on the next image? At the moment I have next view of var_dump() (with <pre>var_dump(...)</pre> , without it will be all in one line) and just plain text for errors. I searched something for PHP colored errors, var_dump styles, but could not find anything. I used OpenServer as localhost, and on previous version I had same styles for errors, but now just plain text. Is it real to customize? 回答1: You get the colored output

Looking for a more flexible tool than GNU indent

被刻印的时光 ゝ 提交于 2019-12-23 08:26:23
问题 When I run indent with various options I want against my source, it does what I want but also messes with the placement of *s in pointer types: -int send_pkt(tpkt_t* pkt, void* opt_data); -void dump(tpkt_t* bp); +int send_pkt(tpkt_t * pkt, void *opt_data); +void dump(tpkt * bp); I know my placement of *s next to the type not the variable is unconventional but how can I get indent to just leave them alone? Or is there another tool that will do what I want? I've looked in the man page, the info