func()

in resources/resources.go [290:316]


func (k Kernel) MarshalJSON() ([]byte, error) {
	rawFields := make(map[string]any)
	for key, v := range k.rawFields {
		rawFields[key] = v
	}
	if len(k.ID) > 0 {
		rawFields["id"] = k.ID
	}
	if len(k.SpecID) > 0 {
		rawFields["name"] = k.SpecID
	}
	if len(k.LastActivity) > 0 {
		rawFields["last_activity"] = k.LastActivity
	}
	// Unconditionally set the "connections" field because Jupyter requires it to be present.
	rawFields["connections"] = k.Connections
	if len(k.ExecutionState) > 0 {
		rawFields["execution_state"] = k.ExecutionState
	}
	if len(k.Env) > 0 {
		rawFields["env"] = k.Env
	}
	if len(k.Metadata) > 0 {
		rawFields["metadata"] = k.Metadata
	}
	return json.Marshal(rawFields)
}