senzing-garage / sz-sdk-json-type-definition

[Spike] Codify JSON structure
Apache License 2.0
0 stars 0 forks source link

Figure out how to handle "{}" #34

Closed docktermj closed 2 weeks ago

docktermj commented 5 months ago

When running a testcase like:

func TestSzConfigAddDataSourceResponseTest000(test *testing.T) {
    ctx := context.TODO()
    jsonString := `"{}"`
    jsonStruct := SzConfigAddDataSourceResponse{}
    err := json.Unmarshal([]byte(jsonString), &jsonStruct)
    testError(test, ctx, err)
    _, err = json.Marshal(jsonStruct)
    testError(test, ctx, err)
}

The following error is returned.

json: cannot unmarshal string into Go value of type typedef.AddDataSource

Figure out how to support unmarshalling "{}".

docktermj commented 2 weeks ago

Answer: Change the value in response-testcases.json to:

    "SzConfigAddDataSourceResponse": {
        "tests": {
            "test-000": {},
            "test-001": {
                "DSRC_ID": 1
            }
        }
    },
docktermj commented 2 weeks ago

Fixed via https://github.com/senzing-garage/sz-sdk-json-type-definition/pull/43