当我使用JSON_EXTRACT funciton时,SQLITE中的JSON错误畸形
在我的sqllite表中,我的字段名为config
,它以json文本的形式存储配置。.bellow
是config> config> config> config
字段中
{
"matRid": 1,
"holderType": 1,
"uomRid": 1,
"type": 502,
"stockConditionIndex": 800,
"serialRequired": 1,
"codepart": 1,
"allowEdit": 1
}
从此数据 中存储的示例数据波纹查询它引发畸形的JSON
错误
select json_extract(config, '$.codepart') as codepart FROM TableName
测试JSON是否以正确的格式测试我是否已运行以下查询
select json_valid(config) from TableName
查询retuns 1,这证实了JSON以适当的格式
,以及我运行的是否运行查询直接像Bellow一样,使用字段的JSON值config
查询将成功返回结果,
select json_extract('{
"matRid": 1,
"holderType": 1,
"uomRid": 1,
"type": 502,
"stockConditionIndex": 800,
"serialRequired": 1,
"codepart": 1,
"allowEdit": 1
}', '$.codepart') as codepart FROM TableName
如何通过使用列名来制作JSON_EXTRACT
使用列名而不是JSON值DIRECLTY DIRECLTY在sqllite?
附加信息:SQLite版本3.35.5。
任何建议都会有所帮助..谢谢..
In my sqllite table i have field named config
which stores configuration in the form of json text..
bellow is the sample data stored in config
field
{
"matRid": 1,
"holderType": 1,
"uomRid": 1,
"type": 502,
"stockConditionIndex": 800,
"serialRequired": 1,
"codepart": 1,
"allowEdit": 1
}
from this data when I run the bellow query it throws malformed JSON
error
select json_extract(config, '$.codepart') as codepart FROM TableName
to test whether json is in the correct format or not i have run the following query
select json_valid(config) from TableName
above query retuns 1, this confirms that json is in the proper format
and also if I run the query by directly like bellow, using the json value of the field config
query will return result successfully,
select json_extract('{
"matRid": 1,
"holderType": 1,
"uomRid": 1,
"type": 502,
"stockConditionIndex": 800,
"serialRequired": 1,
"codepart": 1,
"allowEdit": 1
}', '$.codepart') as codepart FROM TableName
How to make json_extract
work by using the column name instead of json value direclty in SqlLite?
additional info : SQLite Version 3.35.5.
any suggestions would be helpfull.. Thank you..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误实际上是由
json_extract
用于排空记录(空字符串)的行 code> config> config通过包括iif语句来解决的行。
The error was actually produced by the
json_extract
for the rows with empty record (empty string) for the fieldconfig
resolved it by including the IIF statement