简体   繁体   English

Windows 终端/Ubuntu 未显示所有带有漂亮打印的响应

[英]Windows terminal/Ubuntu not showing all response with pretty print

When parsing an API response (using pretty print), most of the response is being cut off and just "..." is being shown.解析 API 响应(使用漂亮的打印)时,大部分响应都被截断,只显示“...”。

irb(main):022:0> data = JSON.parse(response.read_body)
=>
{"data"=>
...

How do I display the whole response?如何显示整个响应?

You can type data after the assignment (at the next prompt), and you'll get the entire contents.您可以在分配后(在下一个提示中)键入data ,您将获得全部内容。 If you don't actually need the assignment, and only want to inspect the parsed response, use JSON.parse(response.read_body)如果您实际上不需要分配,而只想检查已解析的响应,请使用JSON.parse(response.read_body)

By the way, the truncation behaviour of IRB is the default, but it can be changed with IRB.CurrentContext.echo_on_assignment = true - see https://docs.ruby-lang.org/en/master/IRB/Context.html顺便说一句,IRB 的截断行为是默认的,但可以使用IRB.CurrentContext.echo_on_assignment = true更改它 - 请参阅https://docs.ruby-lang.org/en/master/IRB/Context.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM