I've got a serialized JSON structure that looks something like
this:
{
"title": "Webpage title",
"major_categories": [
{
"title": "Major Category title",
"categories": [
{
"title": "Minor Category title",
"links": [
{
"url": "http://myurl.something.com",
"label": "Text to display"
}
]
}
]
}
]
}
Of course the arrays have more elements (the entire file is about
450 lines). My thought was to simply iterate through this
structure using std.json and vibe.d/diet and basically build a
webpage that way. My D get request handler is fairly simple:
void get() {
JSONValue json = parseJSON(new File("links.json",
"r").readln('\x00'));
string title = json["title"].str;
JSONValue[] major_categories = json["major_categories"].array;
render!("index.dt", title, major_categories);
}
My Diet is a little more complex, with three layers of foreach
loops:
doctype html
html
head
title #{title}
body
h1 #{title}
- foreach (major; major_categories)
h2 #{major["title"].str}
- foreach (minor; major["categories"].array)
h4 #{minor["title"].str}
p
- foreach (item; minor["links"].array)
a(href="#{item[\"url\"].str}")
#{item["label"].str}
br
I realize all that is hard to read, sorry. :/
Anyway, my problem is that when I get about to line 320 of the
JSON, the diet stops generating HTML. I've spit out the whole
JSON run through the parser and back to string, and that has all
the data, including the stuff that is cut out in the Diet.
Basically I'm pretty sure it's not std.json (not 100% sure, since
the operations I do in the diet are more complex, but
essentially...). Does anyone have any insight to shine on this?

Do you get a response back with rendered html or does the
connection get dropped?
Have you tried to cut down the amount of data and see if it will
render it all? That should eliminate whether it's the amount of
data or what.

Do you get a response back with rendered html or does the
connection get dropped?

No, the html does come in, and the whole content of the
rendered page is sent to the browser. The page has closing head
and body tags.

Have you tried to cut down the amount of data and see if it
will render it all? That should eliminate whether it's the
amount of data or what.

I'll play with that. Would there be any reason for my data to
get randomly truncated?

Before you did:
render!("index.dt", title, major_categories);
Have you tried to check the contents of "major_categories" making
sure it's all there. Just to figure out whether the problem is in
the view rendering or the json parsing.

No, the html does come in, and the whole content of the
rendered page is sent to the browser. The page has closing
head and body tags.

[...]

I'll play with that. Would there be any reason for my data to
get randomly truncated?

Before you did:
render!("index.dt", title, major_categories);
Have you tried to check the contents of "major_categories"
making sure it's all there. Just to figure out whether the
problem is in the view rendering or the json parsing.

On Thursday, 2 November 2017 at 18:48:10 UTC, bauss wrote:
Before you did:
render!("index.dt", title, major_categories);
Have you tried to check the contents of "major_categories"
making sure it's all there. Just to figure out whether the
problem is in the view rendering or the json parsing.