On Thu, 31 Mar 2016 18:58:30 GMT, Sönke Ludwig wrote:
On Thu, 31 Mar 2016 17:18:16 GMT, John More wrote:
I have the following JSON
[{"id":"1234","value":"20","name":"PowerSave"},{"id":"4567","value":"680","name":"PowerNormal"}]I want to deserialize into the following
struct theData { string id; string value; string name; }
I have tried
theData theResposne= deserializeJson!theData(res.bodyReader.readAllUTF8()); theData[] theResposne= deserializeJson!theData(res.bodyReader.readAllUTF8());
and many other variants to no avail.
Suggestions appreciated.Thanks
This should work:
auto theResponse = deserializeJson!(theData[])(res.bodyReader.readAllUTF8());
In the last line you were just missing the
[]
for the template argument.
Thank You.
Given my experience level (greener than green) and a little javascript HTTP experience I thought I could manage this task. However; the problems I experienced (all mine) drove me to explore the auto client = new RestInterfaceClient!DeviceStore("http://xxx.xxx.xxx.xxx:xxxx/"). And WOW from 229 lines of source to 28 lines. This may be nothing new to experienced developers, but to me; whose last serious programming was Z80 assembler, this is Absolutely Amazing .
I sincerely thank you for sharing your knowledge and all your efforts!!!