“We know that governmental data-systems aren’t generally considered ‘cutting edge’ or ‘well architected’, but we’ve brought together some top flight talent, and we’re building a RESTful architecture that guarantees your code gets nice, easy-to-consume JSON objects.”

That’s what Oralee B. was told when she was hired to work on it. The system owned pretty much the entirety of the municipal data management market, tracking birth certificates, marriage certificates, death certificates and pet licenses for nearly every city in the country. JSON is so simple, how can you screw it up?

The same way most people seem to screw it up: reinventing key/value pairs in your key/value data format.

{
    "code": "Registrations",
    "Configurations": [
        {
            "code": "Registration1",
            "Configurations": [
                {
                    "code": "IdRegistration",
                    "value": "94"
                },
                {
                    "code": "CaptionActive",
                    "value": "EF_PRE_CR"
                },
                {
                    "code": "DateEnd",
                    "value": "2019-01-01"
                },
                {
                    "code": "DateStart",
                    "value": "2019-01-01"
                },
                {
                    "code": "Units",
                    "Configurations": []
                }
            ]
        },
        {
            "code": "Registration2",
            "Configurations": [
                {
                    "code": "IdRegistration",
                    "value": "92"
                },
                {
                    "code": "CaptionActive",
                    "value": "EF_PRE"
                },
                {
                    "code": "DateEnd",
                    "value": "2019-01-01"
                },
                {
                    "code": "DateStart",
                    "value": "2019-01-01"
                },
                {
                    "code": "Units",
                    "Configurations": [
                        {
                            "Code": "Unit1",
                            "Value": null,
                            "Configurations": [
                                {
                                    "code": "IdUnit",
                                    "Value": "1",
                                    "Configurations": []
                                },
                                {
                                    "code": "CaptionUnit",
                                    "value": "Hour",
                                    "Configurations": []
                                }
                            ]
                        },
                        {
                            "Code": "Unit2",
                            "Configurations": [
                                {
                                    "code": "IdUnit",
                                    "Value": "2",
                                    "Configurations": []
                                },
                                {
                                    "code": "CaptionUnit",
                                    "value": "Entrance",
                                    "Configurations": []
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

It’s not just the reinvention of key/value pairs as code/value pairs. They’re also reinvented as Code/value and Code/Value pairs. The inconsistent capitalization tells its own story about how this JSON is generated and consumed by other clients, and at least on the generation side, it clearly rhymes with “bling congratulation”.

When Oralee asked, “Why on Earth do you do it this way?”

“Because,” her boss explained, “this is the way we do it.”

[Advertisement] ProGet supports your applications, Docker containers, and third-party packages, allowing you to enforce quality standards across all components. Download and see how!