Skip to content

JsonSyntaxException related to status.conditions[0].lastTransitionTime #11

Open
@dzhi-lyft

Description

@dzhi-lyft

Hit following error to parse getNamespacedCustomObject() result into KruiseAppsV1alpha1CloneSet (gson 2.8.9).

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at path $.status.conditions[0].lastTransitionTime

unfortunately I don't have the status.conditions[0].lastTransitionTime field as it does not normally exists in the cloneset object and we didn't save a copy when it happened (I will add an example if this happens again in the future). I wonder whether there is a possible mismatch between the expected and real format of the field. Or like to know if there is a better way to obtain KruiseAppsV1alpha1CloneSet from the returned obj.

    ApiClient client = Config.defaultClient();
    Configuration.setDefaultApiClient(client);
    CustomObjectsApi customObjectsApi = new CustomObjectsApi(client);
    Object obj = customObjectsApi.getNamespacedCustomObject(
        "apps.kruise.io",                 // group
        "v1alpha1",                       // version
        K8sCommon.getNamespaceFromEnv(),  // namespace
        "clonesets",                      // plural
        cloneset                          // name
    );

    Gson gson = new JSON().getGson();
    KruiseAppsV1alpha1CloneSet v1cs = gson.fromJson(
        gson.toJsonTree(obj).getAsJsonObject(), KruiseAppsV1alpha1CloneSet.class);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions