datawire / quark

Quark is a specialized language for defining and implementing communication protocols in multiple languages.
http://datawire.github.io/quark/
Apache License 2.0
98 stars 24 forks source link

Quark 1.0 can't convert Map<String, String> to JSON #189

Open kflynn opened 8 years ago

kflynn commented 8 years ago

This is a regression since 0.7.

In check.q:

quark 1.0;

namespace check {
    String Check(String p1) {
        Map<String, String> params = { "p1": p1 };

        // ...and the JSON for the request body...
        JSONObject jParams = params.toJSON();
        String jsonParams = jParams.toString();

        return jsonParams;
    }
}

quark install --python --javascript check.q, then in Python:

from check import Check
print(Check("hello"))

and in JavaScript:

var Check = require('check').check.Check;
console.log(Check("hello"));

In both cases the output is {"p1":{"$class":"quark.Object"}}.

(I didn't try Java or Ruby. Identical brokenness in two of the target languages implies not a target language problem.)

ark3 commented 8 years ago

Hopefully fixed in 3fb719e

ark3 commented 8 years ago

I enabled the test in quarkc/test/lib/map_test.q so we shouldn't break this again. However, my "fix" is not a good one, to be sure.