Http.ExecuteRequestAsJson ClassCastException

@Koen_Kraak
I didn’t know what file had the tantative fix or how to use the Sugar project from http://github.com/remobjects/Sugar since it has no .jar file to use as reference. (Sorry im still new)

What I did and what worked for me was using the Http.ExecuteRequestAsString method and with the following utility class to wrap JsonArray’s in a JsonObject with a prefix for example instead of the json supplied in my first post it will look like:
{
“data”:[
{
“description”: “Population on 1 January”,
“id”: 1,
“maxValue”: 520000000,
“minValue”: 0,
“unit”: “people”
}
]
}

// Utility class I wrote for wrapping:
public class JsonUtils{

// Method to convert a string that is in json format to a JsonDoc
// without the ClassCastException
// @NOTE: no check performed to identify if valid JSON
// @param jsonArrayKey,                 The key to add if root is a JsonArray
public static func stringToJsonDoc(jsonString: sugar.String, jsonArrayKey: sugar.String) -> sugar.json.JsonDocument{
    var jsonFormattedString = jsonString
    // Make sure it can be converted to a JsonDocument by making it an JsonObject if it is a JsonArray
    if(isJsonArray(jsonString)){
        jsonFormattedString = "{\"" + jsonArrayKey + "\"" + ":" + jsonFormattedString + "}"
    }
    return sugar.json.JsonDocument.FromString(jsonFormattedString)
}

// Method to check if a json formatted string is a JsonArray
private static func isJsonArray(jsonString: sugar.String) -> Bool {
    return jsonString.getChars(0) == "["
}

}

So the usage of it will be for example:
// response is sugar.HttpResponseContent<sugar.String!>! which is returned by the method Http.ExecuteRequestAsString
var jsonDoc: sugar.json.JsonDocument = JsonUtils.stringToJsonDoc(response.Content, jsonArrayKey:“data”)

Hope this helps someone who is facing the same issue