Workaround for "fields have different lengths"
See original GitHub issueHi, I understand what is meant by Fields have different lengths, but is there any workaround to avoid this without losing any array elements by coalescing missing values to some default? It’s a critical requirement for us.
For example, form the following input:
{
"services": [
{
"name": "order-api",
"version": "1"
},
{
"name": "billing-api"
}
]
}
I want to get ["order-api", "billing-api"]
for name
field, ["1", ""]
for version
field.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Workaround for "fields have different lengths" #144 - GitHub
Hi, I understand what is meant by Fields have different lengths, but is there any workaround to avoid this without losing any array...
Read more >JSON API datasource returning "Fields have different lengths ...
When querying a datasource that returns the following structure, the JSON API give the “Fields have different lengths” when set the field ......
Read more >Input and select fields have different lengths - Stack Overflow
I have a form with different types of fields ...
Read more >How to solve the problem of different length for the same field
A solution would be to create a new structure and add a new field with length 35: 1. Create a type. BEGIN OF...
Read more >Merge datasets with unequal field lengths - Esri Community
I have several shapefiles that I want to merge together into one shapefile so I don't have to ... Workaround to increase the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think (hope, guess) I have found a workaround. For me at least it works around the issue of missing fields. Maybe it helps others, too. Let me know how universal that is. The trick for me was to use JSONata instead of JSONPath for the affected fields. Took a little bit of time to get used to it, but I have a few issues sorted out now. Two features in JSONata seem important to me:
Here’s a very basic JSONata expression that does it for me with the field “h” (for “hours”)
$.rows.($count(h) > 0 ? ( $string(h) = "null" ? "Null value" : h ) : "Empty Value")
Explanation:
Condition ? True : False
syntax) setting default / replacement values for 2 different “empty field” situations, depending on what the JSON API returns$string(h[0])
, but$string(h)
works fine for meHope this helps someone
Yes, that’s better explanation than mine 😃
Thank you for taking the time to look into this 🙏 One of my plans for the next major release is to rewrite it into a backend plugin (in Go) to support alerting. The tricky thing will be to find a JSONPath library for Go. Unfortunately, switching to any other library will likely make it hard to maintain feature parity.
I’ll be somewhat unavailable this week, but I’m planning to spend the next two weeks of my vacation on plugin work, I might take the opportunity to start working on this then.