我可以在Liferay实体中保存对象吗?
我已经通过service.xml创建了Liferay实体。我可以将JSON对象保存在字符串列中并像API一样返回此值吗?现在,对“ JSON”的响应是这样的:
{
"name": "test",
"time": 1656067273906,
"longitude": 00.00000,
"latitude": 00.00000,
"Json": "{"name":"test", "depth":"0", "main":"true", "power":"0"}",
"description": "test",
}
但是我希望在没有引号的情况下获得“ json”价值,例如:
{
"name": "test",
"time": 1656067273906,
"longitude": 00.00000,
"latitude": 00.00000,
"Json": {"name":"test", "depth":"0", "main":"true", "power":"0"},
"description": "test",
}
I have created liferay entity by service.xml. Can I save Json object inside string column and return this value like object from api? Now the response for "json" is this:
{
"name": "test",
"time": 1656067273906,
"longitude": 00.00000,
"latitude": 00.00000,
"Json": "{"name":"test", "depth":"0", "main":"true", "power":"0"}",
"description": "test",
}
But I hope to obtain "json" value without quotes, like this:
{
"name": "test",
"time": 1656067273906,
"longitude": 00.00000,
"latitude": 00.00000,
"Json": {"name":"test", "depth":"0", "main":"true", "power":"0"},
"description": "test",
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在
service.xml
中编写的实体具有远程服务
属性设置为true
,例如,和一个名为
的文本字段info
(例如)在其中存储一个JSON字符串,然后可以在<您的服务模块src>/service/impl/employeeserviceimpl.java
中编写方法包含来自服务实体的数据。例如,您可以将方法添加到employserviceimpl
之后,运行
buildservice
任务,然后构建
deploy> exploy 捆。您会找到mycustompothod
作为JSONWS API。If the entity you wrote in
service.xml
has theremote-service
attribute set totrue
, for exampleand a text field named
info
(for example) in which you store a JSON string, then you can write a method in<your service module src>/service/impl/EmployeeServiceImpl.java
that returns a JSONObject containing the data from your service entities. For example you can add a method toEmployeeServiceImpl
classAfter that, run the
buildService
task thenbuild
anddeploy
your bundles. You will findmyCustomMethod
as JSONWS Api.