| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Sumo 19.10.2023 07:49
Настроить json:string для вашего примера несложно.@main[]
$props[^table::create{prop
wind
dewpoint
rh
pressure
}]
$levels[^table::create{level
surface
"800h-3"
300h
}]
$post[
$.key[abcd123]
$.lat(49.809)
$.lon(16.787)
$.model[gfs]
$.parameters[$props]
$.levels[$levels]
]
json:string:
^json:string[$post][
$.indent(true)
$.table[compact]
]
custom:
^post2json[$post]
@post2json[post]
^apply-taint[json][{
"key": "^taint[$post.key]",
"lat": ^post.lat.format[%.3f],
"lon": ^post.lon.format[%.3f],
"model": "^taint[$post.model]",
"parameters": [^post.parameters.foreach[;v]{"^taint[$v.prop]"}[, ]],
"levels": [^post.levels.foreach[;v]{"^taint[$v.level]"}[, ]]
}]Результат: json:string:
{
"key":"abcd123",
"lat":49.809,
"lon":16.787,
"model":"gfs",
"parameters":[
"wind",
"dewpoint",
"rh",
"pressure"
],
"levels":[
"surface",
"\"800h-3\"",
"300h"
]
}
custom:
{
"key": "abcd123",
"lat": 49.809,
"lon": 16.787,
"model": "gfs",
"parameters": ["wind", "dewpoint", "rh", "pressure"],
"levels": ["surface", "\"800h-3\"", "300h"]
}