Is it possible to get the whole object from debugger as Json? There is an option View text but can I somehow View JSON?

推荐答案

编辑:正如 comments 中所指出的,这并不完美,因为对于某些变量,您将得到"stackoverflow"响应

正如@Mr Han's answer所建议的,以下是你可以做到这一点的方法:

添加一种新方法,通过以下方式将Intellij调试器中的对象视为json

  • Going to File | Settings | Build, Execution, Deployment | Debugger | Data Views | Java Type Renderers
  • 单击+添加新渲染器
  • Call it JSON renderer
  • Supply java.lang.Object for Apply renderer to objects of type
  • Select Use following expression:并提供如下表达式:
if (null == this || this instanceof String)
  return this;

new com.google.gson.GsonBuilder().setPrettyPrinting().create().toJson(this);
  • Click OK
  • Now when you choose Copy Value on a variable, it will copy as json. enter image description here

Json相关问答推荐

如何创建生成两个不同对象的JSON数组的SQL查询?

使用Kotlin限制序列化类属性的允许整数值

在深度嵌套数组中使用布尔属性的jq-select

错误:在 NX 工作区中找不到模块../swagger.json

将不带正文的 CURL POST 转换为 RESTRequest Delphi 代码 / 为 Dropbox API /get_current_account 端点编写 Delphi 代码

遍历 JSON,检索父值

如何在 JSonPath 中按值查找列表中的所有元素

JOLT 转换仅过滤一个字段

如何使用 Google 表格应用程序脚本将 JSON 中的多个字段提取到 Google 表格中

Go - JSON 验证抛出错误,除非我在 struct 中使用指针.为什么?

在 postgresql 中将行转换为 json 对象

Swift - 将图像从 URL 写入本地文件

Flask 请求和 application/json 内容类型

Jackson Scala 模块的小例子?

json和空数组

关于使用 $ref 的 JSON 模式

如何访问 JSON 对象数组的第一个元素?

JSON日期到Java日期?

无法将空值放入 JSON 对象

JSON - 是否有任何 XML CDATA 类似功能?