Skip to content

Poor JSON response structure #32

@simpleshadow

Description

@simpleshadow

Really dig what you've done @meetDeveloper! Was not aware that Google is using Oxford Dictionaries behind the scenes.

While I really dig the API, the current structure of the API responses makes it very unusable (at least in my JavaScript web-based client). Having values as keys is non-standard and iterating over them is a nightmare. For example, the meaning property should be an array and contain a standard object response with partOfSpeech (e.g. { "partOfSpeech": "noun", ... }).

I'd suggest a response that takes cues from the JSON:API spec.

Here's an example of the suggested improvement to the current structure:

{
    "word": "work",
    "phonetic": [
        "wəːk"
    ],
    "meanings": [{
        "partOfSpeech": "noun",
        "definitions": [
            {
                "definition": "activity involving mental or physical effort done in order to achieve a purpose or result.",
                "example": "he was tired after a day's work in the fields",
                "synonyms": [
                    "labour",
                    "toil",
                    "exertion",
                    "effort",
                    "slog",
                    "drudgery",
                    "the sweat of one's brow"
                ]
            },
            {
                "definition": "a task or tasks to be undertaken.",
                "example": "they made sure the work was progressing smoothly",
                "synonyms": [
                    "tasks",
                    "jobs",
                    "duties",
                    "assignments",
                    "commissions",
                    "projects"
                ]
            }
        ]
    }, {
        "partOfSpeech": "verb",
        "definitions": [
            {
                "definition": "be engaged in physical or mental activity in order to achieve a result; do work.",
                "example": "an engineer who was working on a design for a more efficient wing",
                "synonyms": [
                    "toil",
                    "labour",
                    "exert oneself",
                    "slave (away)",
                    "plod away"
                ]
            },
            {
                "definition": "(of a machine or system) function, especially properly or effectively.",
                "example": "his phone doesn't work unless he goes to a high point",
                "synonyms": [
                    "function",
                    "go",
                    "run",
                    "operate",
                    "perform"
                ]
            }
        ]
    }]
}

Regrettably, I'm going to use the Oxford Dictionaries API.

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