Telenav / kivakit

KivaKit is a set of integrated Java mini-frameworks for everyday development.
Apache License 2.0
83 stars 10 forks source link

Invalid response JSON when response is null #141

Closed jonathanl-telenav closed 2 years ago

jonathanl-telenav commented 2 years ago

Description

When the response object is null the response is invalid:


{
,
"error": []
}
jonathanl-telenav commented 2 years ago

I don't have an easy test case for this, but checking for an empty payload like this should fix it:


                        writeResponse("{");
                        var payload = stripBrackets(toJson(response));
                        if (!payload.isEmpty())
                        {
                            writeResponse(payload + ",");
                        }
                        writeResponse(stripBrackets(toJson(errors)));
                        writeResponse("}");
jonathanl-telenav commented 2 years ago

fixed in https://github.com/Telenav/kivakit-extensions/pull/43