Skip to content

decodeMapFromString converts escaped strings to numerics #77

@jmeberlein

Description

@jmeberlein

For a bit of context, I'm trying to make an app to figure out the readings and psalms for the Daily Office from the BCP, and I've formatted everything in YAML for better multi-line string support. However, this also means I have a lot of values that are just a number like 34 and a lot of keys that are dates formatted as MMdd. For example:

'0101':
  evening:
    psalter: '148'
  morning:
    psalter: '103'

The data's freeform enough that I'm just loading it into a Map<String?, Any?> with decodeMapFromString, so I can do some post-processing. But despite escaping everything to clearly mark them as strings, it's casting them to numbers. For example, (and ironically using JSON to display the expected results) it's giving me the map:

{
  "101": {
    "evening": {
      "psalter": 148
    },
    "morning": {
      "psalter": 103
    }
  }
}

not:

{
  "0101": {
    "evening": {
      "psalter": "148"
    },
    "morning": {
      "psalter": "103"
    }
  }
}

like I expect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions