Skip to content

Help with creatng a templated function to accept JSON arrays? #4437

Answered by gregmarr
DylanPerez04 asked this question in Q&A
Discussion options

You must be logged in to vote

Your major problem is that you aren't doing anything to specify the type of the array you're reading in jsonToArray. Since you are not taking in any parameters that have anything to do with the type T, you need to specify it as in jc::jsonToArray<int>(....

You have a variety of other errors that may just be that you haven't finished filling things in, such as allocating a single element of type T rather than an array of T, you aren't filling in the array, and you aren't doing anything with the returned array.

Some of those are fixed here:
https://www.godbolt.org/z/9d3qPTbWW

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@DylanPerez04
Comment options

Answer selected by DylanPerez04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants