问题标签 [qjson]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
737 浏览

qt - Qt - 对 QJsonValue::toString 的未定义引用

我正在尝试在 Linux 上使用 Qt 5.7 构建示例项目。以前,使用 Qt 5.4.2 构建了相同的项目,没有问题。当我尝试使用 Qt 5.7 时,出现以下错误:

我尝试使用Qt 维护工具安装 Qt5.7,还从 Qt 官方网站下载并使用 .run 文件安装它。当我对 qjsonvalue 运行定位时,我得到以下结果:

根据之前的结果,似乎我需要安装一些东西,因为 qjsonvalue.h/cpp 不在我的 Qt5.7 核心中。关于如何解决它的任何想法?需要安装其他东西吗?注意,当我启动 Qt 维护工具时,我收到一条警告消息,内容如下:

0 投票
2 回答
75 浏览

javascript - jQuery:如何使 selectall 对复选框起作用

我有以下代码返回复选框的值如何全选/取消全选并获取所有选定的值?

JS

0 投票
1 回答
4879 浏览

qt - 使用 QSettings 或 QJson 保存 UI 设置?

保存 UI 设置QSettings既麻烦又麻烦,因为每次您必须使用setValue()value()函数并定义组、应用程序名称和组织,这在大型应用程序中可能是错误的:

但是使用 JSON 可以更简单:

保存和恢复 ui 设置的最佳做法是什么?

  • 将每个键/值保存在QSettings?

  • 存入QJson,然后用QSettings?

  • 仅保存QJson(使用另一种定义组和应用程序的机制)?

还有什么想法吗?

0 投票
1 回答
64 浏览

json - 以下以 Json 字符串为输入的 Qt QStrings 有什么区别?使用 QTcpSockets

我有一条 json 消息要通过 QTcpSocket 发送。在发送消息之前,Json 消息的格式如下:

情况1 :

案例2:`

当 QString 准备好时,它通过 QTcpSocket 传输,如下所示:

在接收端,套接字在这两种情况下都能接收数据。但是当使用 QJsonDocument 解析接收到的数据时,案例 1 无法提供空的 json 文档,而案例 2 可以提供所需的 JsonDoc。

这是接收端代码:

两种情况有什么区别?两者之间最好的方法是什么?

0 投票
1 回答
731 浏览

c++ - How to parse escape sequences in QString?

I have a QString that I need to insert it to a QJsonArray. The problem is that the string is inserrted as it is and the escape sequences doesnot work.

Here, the qstring is populated with the values from "id" and "name" (these are also QString) and then inserted to qjsonarray. The labellist here is a QJsonArray. The inputs to the QString are say for example "55" and "ggg". When I print the qstring like

it gives me

but if I insert it to the labellist and print the labellist it gives:

The format of the QJsonvalues in the above array is lost.

How to decode the string to preserve the format and make the escape sequences work?

0 投票
1 回答
1141 浏览

c++ - 如何创建 QJsonDocument?

我想创建一个QJsonDocument但我找不到将我的数据推送到文档中的方法。在JsonBuilder::CreateContact我的文件末尾似乎是空的。请提供一些帮助 X)。

我尝试使用一些指针并将它们添加到我的文档中,因为我正在考虑销毁我的不同对象(contactObj, detailObj, addressObj, date)但是使用这种方法我无法构建类型QJsonValue(无法访问private成员QjsonValue::QJsonValue)所以我错了吗 ?

JsonBuilder.h

JsonBuilder.cpp

0 投票
2 回答
309 浏览

c++ - 无法将“QJsonObject”转换为“int”作为回报

所以我有:

我的ListElements方法声明QJsonObject,用我需要的东西填充它,并且应该返回对象,以便它可以被推送到nodeCollection数组变量:

我得到的错误是:

error: cannot convert 'QJsonObject' to 'int' in return

我显然是 C++ 的新手,我已经成功地用谷歌搜索了这个问题,但没有具体的例子来解决这个问题。

我究竟做错了什么?我怎样才能告诉它应该返回的方法QJsonObject而不是int

0 投票
2 回答
2935 浏览

c++ - 如何将 QVariant 转换为 QJsonValue?

如何转换QVariantQJsonValue?我知道QVariant提供该toJsonValue功能,但它没有按预期执行。

例如:

两者都返回:

期望输出:

0 投票
1 回答
326 浏览

c++ - QJsonValue 变空

当我向时间 API 发出请求以获取莫斯科时间时,int变量中的内容为空。这是代码:

这是 JSON:

0 投票
1 回答
1339 浏览

android - 从没有数组名的 QJsonarray 获取 QJsonObjects

我是 QT 的新手,我创建了一个 HTTP 服务器,服务器将在 Windows 上运行,客户端在 android 上运行,服务器将获得 JSON 格式的 POST 请求和响应,如下所示:

json响应:

服务器代码:

如何从所有动态对象中获取 FName、LName。我想使用 qt 类,因为我正在 Qt 中为 android 创建客户端。

我在 Windows 上使用 QT5.9.2 任何示例......