You're trying to insert an array, not a single record, from your JSON, but in your Apex Code, you're trying to deserialize just a single question. Instead, you can do this:
Question__c[] records = (Question__c[])JSON.deserialize(questionData, List<Question__c>.class);
Also, using remote action methods, you can SObjects in directly:
@RemoteAction public static String insertQuestions(Question__c[] questionData) {
This skips the bit about having to deserialize it manually, but you can't catch those errors in Apex Code either, if you use this technique. It also might require some small change to your JavaScript to include an "attributes" parameter (deserialize a standard SObject to see what I'm talking about).
Omitting the rest of the structure for brevity, you can do something like the following:
'[{"id": "' + prId + '"}]`
I tend to prefer creating a class to represent the structure and then serialize that.
class MyObject
{
Id id;
String name;
DateRange dateRange;
}
class DateRange
{
String startDate, endDate;
}
Then in your test:
MyObject instance = new MyObject();
instance.id = prId;
instance.name = 'abc123';
instance.dateRange = new DateRange();
instance.dateRange.startDate = '2020-02-17';
instance.dateRange.endDate = '2020-02-26';
String myJSON = JSON.serialize(instance);
Best Answer
This is JSON (note the double not single quotes):
To ensure that no characters that have special meaning in a URL are included, put the JSON String through EncodingUtil.urlEncode when you add it to the URL and through EncodingUtil.urlDecode when you take it out of the URL.
The above JSON encodes to:
This approach is best used with quite short JSON (a few hundred characters) as maximum URL length limits across the internet are somewhat unpredictable.