read_json not being determined as a Map
See original GitHub issueI’m using read_json to read the contents of a file with a json output, and then immediately trying to access a property on this (through the following minimal example):
version development
task readjson {
command <<<
echo '{"out": "Hello, WDL!"}' > out.txt
>>>
output {
String out = read_json('out.txt')["out"]
}
}
This validates and runs correctly in Cromwell, but in miniWDL I get the following error:
miniwdl run --verbose codetool.wdl
(codetool.wdl Ln 10 Col 18) Not an array
String out = read_json('out.txt')["out"]
^^^^^^^^^^^^^^^^^^^^
I’ve noticed that you can coerce it to the correct type which will then validate, eg:
version development
task readjson {
command <<<
echo '{"out": "Hello, WDL!"}' > out.txt
>>>
output {
Map[String, String] coercedmap = read_json('out.txt')
String out = coercedmap["out"]
}
}
But this has the disadvantage that it returns more than what’s required.
Versions:
v0.6.3
(through Pip)- Latest on Git:
miniwdl v0.6.4.dev14
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Read JSON file and map to C# objects - Stack Overflow
I want to read a JSON file and map ...
Read more >Spark from_json() - Convert JSON Column to Struct, Map or ...
In Spark/PySpark from_json() SQL function is used to convert JSON string from DataFrame column into struct column, Map type, and multiple columns.
Read more >A Complete Guide to JSON in Golang (With Examples)
This post will describe how to marshal and unmarshal JSON in Go. We will learn how to convert from JSON raw data into...
Read more >JSON and serialization - Flutter documentation
Unfortunately, jsonDecode() returns a Map<String, dynamic> , meaning that you do not know the types of the values until runtime.
Read more >How to serialize and deserialize JSON using C# - .NET
Use the library directly, not through a framework such as ASP. ... The preceding examples use type inference for the type being serialized....
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 FreeTop 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
Top GitHub Comments
@illusional the solution in just-released v0.7.1 is very much along the lines you suggested, but exapts some type unification logic that had existed elsewhere for other purposes. There will probably still be some weird corner cases like non-homogeneity in lists and object value types, as you mention – let us know if you hit anything that clearly ought to work even given that JSON isn’t 100% embeddable in WDL values. Thanks!
Thanks – yea, looks like I punted on this case previously. Will take another look