Closed bubnenkoff closed 8 years ago
toJSONValue
is the function that you are looking for. The difference is that parse
only parses up to the end of the first JSON "value" that it finds ("value" meaning literal, object or array), leaving the rest of the input range untouched. to
on the other hand assumes and enforces that the complete input string only contains a single value. The naming was chosen to be in line with std.conv
. However, this issue has been brought up a number of times now, so obviously it isn't very intuitive.
I'll close this as a duplicate of #14 and keep that open.
"String is a valid range, but parseJSONValue takes a reference to a range, because it directly consumes the range and leaves anything that appears after the JSON value in the range. toJSON() on the other hand assumes that the JSON value occupies the whole input range." you wrote this answer on forum.dlang.org when I asked about why function do not accept strings.
But what problem is to add strings? Could you explain please