Skip to content

JsonThriftSerializer produces invalid JSON for maps with integer/enum keys #191

Open
@arkadiyt

Description

@arkadiyt

Consider the following thrift struct:

struct TestStruct {
  1: optional map<i64, string> map;
}

When I serialize it with JsonThriftSerializer:

import com.twitter.scrooge.JsonThriftSerializer

val testStruct = TestStruct(Some(Map(1L -> "")))
val serializer = JsonThriftSerializer(TestStruct)
serializer.toString(testStruct)

I expect to get:

{"map":{"1":""}}

I actually get:

{"map":{1:""}}

which is not valid json. For instance attempting to parse with jq:

$ echo '{"map":{1:""}}' | jq .
parse error: Object keys must be strings at line 1, column 10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions