json - 将时间戳转换为液体(json)中的字符串时出错
问题描述
我正在使用逻辑应用程序在存储之前转换我的数据。为此,我使用 json 到 json 内置转换器,它使用液体。这是我的原始输入,
{
"type":"FeatureCollection",
"metadata":{
"generated":1539147197000,
"url":"https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&starttime=2018-10-09T04:53:16.6743076Z",
"title":"USGS Earthquakes",
"status":200,
"api":"1.5.8",
"count":245
},
"features":[
{
"type":"Feature",
"properties":{
"mag":1.9,
"place":"118km NNW of Arctic Village, Alaska",
"time":1539146474786,
"updated":1539146692433,
"tz":-540,
"url":"https://earthquake.usgs.gov/earthquakes/eventpage/ak20275217",
"detail":"https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=ak20275217&format=geojson",
"felt":null,
"cdi":null,
"mmi":null,
"alert":null,
"status":"automatic",
"tsunami":0,
"sig":56,
"net":"ak",
"code":"20275217",
"ids":",ak20275217,",
"sources":",ak,",
"types":",geoserve,origin,",
"nst":null,
"dmin":null,
"rms":1.17,
"gap":null,
"magType":"ml",
"type":"earthquake",
"title":"M 1.9 - 118km NNW of Arctic Village, Alaska"
},
"geometry":{
"type":"Point",
"coordinates":[
-146.6925,
69.1011,
0
]
},
"id":"ak20275217"
},
...(list continues)
这是我在逻辑应用程序中映射的液体文件,
{
"Data": [
{% for f in content.features %}
{
"type": "{{f.properties.type}}",
"mag": {{f.properties.mag}},
"place": "{{f.properties.place}}",
"time": "{{f.properties.time}}",
"tsunami": {{f.properties.tsunami}},
"code": "{{f.properties.code}}",
"ids": "{{f.properties.ids}}",
"magType": "{{f.properties.magType}}",
"source": "{{f.properties.sources}}",
"longitude": {{f.geometry.coordinates[0]}},
"latitude": {{f.geometry.coordinates[1]}}
},
{% endfor %}
]
}
它实际上提供了所需的输出,但对于时间字段,它只是给出了一个错误,如下所示,
"time": "液体错误:值对于 Int32 来说太大或太小。",
我尝试使用本指南将此字段转换为字符串,
但是似乎没有任何效果,并且它给出了类型转换错误。我只想将时间值按原样(甚至作为字符串)保存在原始输入文件中,这是一个 Unix 纪元时间戳。
谢谢
解决方案
尝试追加:'' | f.时间
关键是首先将其强制为字符串。
推荐阅读
- xmpp - ejabberd - 无法将自定义 IQ 发送给其他用户
- python - 使用来自 Db2 (Warehouse) on Cloud 的凭据来初始化 flask-sqlalchemy
- python - Scrapy KeyError: 0 解析下一页
- python - Django datetime.date.min 和 Mysql DATE 最小值不同
- java - Thymeleaf - 一次加载元数据并在所有页面中使用
- android - Android 上内容过长时的 vCard 导入问题
- python - 如何使用 xlsxwriter 以英寸为单位设置行高?
- swift - 来自字符串的 Swift DateFormatter 日期在 NSDateFormatter 曾经工作的地方失败
- php - 将应用程序升级到 CodeIgniter 3 后出现问题
- c++ - 为什么我不能在循环中更改指针的内容?